Protected Sub btnEnter_Click( ) Handles btnSubmit.Click
Dim str As String
str = "select field1 , field2 from table_name where field1=" & Trim(txtval.Text) & " and field2='somevalue' and tdate='"
& txtdate.SelectedDate & "'"
Dim datareader_rad As SqlClient.SqlDataReader
Dim sqlcommandname As New SqlCommand(str, con)
con.Open()
datareader_rad= sqlcommandname.ExecuteReader
If datareader_rad .Read Then
Try
Response.Write("<script language='javascript'>alert('already value is there in list.');</script>")
Catch ex As Exception
Finally
con.Close()
End Try
Else
con.Close()
dr.Close()
Try
cmd = New SqlCommand("stoted_procedure_name", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@field1", Trim(txt1.Text))
cmd.Parameters.AddWithValue("@tablefield2", Trim(txt2.Text))
cmd.Parameters.AddWithValue("@time", Trim(txttime.Text))
Catch ex As Exception
End Try
End If
End Sub
What i did here just took one datareader and stored value , means stored field all value into datareader then checked using datareader_rad .read it shows if value already present in datareader then will show alert box that "already value is entered".
Response.Write("<script language='javascript'>alert('already value is entered.');</script>")
by this code we can learn about javascript in code behind page in asp.net using vb.net
0 comments: