in asp.net+vb web there is a dropdownlist1(in which AL, CL are listed) and there is two textboxes lvetxt.text and bal.text (both are numerial. numbers are fed)
in database No, al_avl, cl_avl are teh fields
i used the following query in vb to update the data
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("16ConnectionString").ConnectionString
con.Open()
Dim qstr2, qstr3 As String
If DropDownList1.Text.Contains("CL") = True Then
qstr2 = "update LEAVE set CL_Avl=@a,no=@no where no=@no"
Dim sqlcom2 As New SqlCommand(qstr2, con)
sqlcom2.Parameters.Add(New SqlParameter("@a", SqlDbType.VarChar, 50)).Value = bal.Text + lvetxt.Text
sqlcom2.Parameters.Add(New SqlParameter("@no", SqlDbType.VarChar, 200)).Value = potxt.Text
Else
qstr3 = "update LEAVE set AL_Avl=@a,no=@no where no=@no"
Dim sqlcom1 As New SqlCommand(qstr3, con)
sqlcom1.Parameters.Add(New SqlParameter("@a", SqlDbType.VarChar, 50)).Value = bal.Text + lvetxt.Text
sqlcom1.Parameters.Add(New SqlParameter("@no", SqlDbType.VarChar, 200)).Value = potxt.Text
End If
Dim sqlcom1 As New SqlCommand(qstr3, con)
Dim sqlcom2 As New SqlCommand(qstr2, con)
sqlcom1.ExecuteNonQuery()
sqlcom2.ExecuteNonQuery()
Page.ClientScript.RegisterStartupScript(Me.GetType, "Forms", "<script> alert('Data Updated successfully ..........')</script>")
End Sub
while browsing
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'sqlcom1' is not declared.
Source Error:
|
Line 249: 'Dim sqlcom2 As New SqlCommand(qstr2, con)
Line 250:
Line 251: sqlcom1.ExecuteNonQuery()
|