在运行下面的代码之后..
Dim p As String = sqlcomm1.ExecuteNonQuery()
字符串 p 正在加载-1
,但查询在 sqlserver 中给出了正确的输出
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim customerID, billno, billdate, Nettotal As String
customerID = DropDownList1.SelectedValue
billno = TextBox1.Text
billdate = TextBox4.Text
Nettotal = TextBox10.Text
Dim sqlcon As New SqlConnection("Data Source=192.168.0.22\SQLEXPRESS;Initial Catalog=Sales_oct_3;Persist Security Info=True;User ID=a;Password=so")
If sqlcon.State = ConnectionState.Open Then
sqlcon.Close()
End If
sqlcon.Open()
Dim strcommand As String
Dim strcommd1 As String
strcommand = "Insert into tinsales(customerID,Billno,Billdate,Nettotal) values ('" + customerID + "','" + billno + "','" + billdate + "','" + Nettotal + "')"
strcommd1 = "select max(salesId) as salesID from [tinsales]"
Dim sqlcomm As New SqlCommand(strcommand, sqlcon)
Dim sqlcomm1 As New SqlCommand(strcommd1, sqlcon)
Dim o As String = sqlcomm.ExecuteNonQuery()
Dim p As String = sqlcomm1.ExecuteNonQuery()
Dim total As Double = 0 For Each gvr As GridViewRow In GridView1.Rows Dim temp As Double = Convert.ToDouble(gvr.Cells(4).Text) total += temp Next TextBox10.Text = total.ToString()