以下のコードを実行した後..
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()