northwind database

  • Thread starter Thread starter muhammadanzar
  • Start date Start date
M

muhammadanzar

Guest
hi,

i want to insert data in order,orderdetail and update in product. kindly see the code, some time i got some error. the code is given below. please correct me.

Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
Using connection As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True")
Using command As New SqlCommand("insert into orders(customerid,employeeid,shipvia) values(@customerid,@employeeid,@shipvia)", connection)
command.Parameters.AddWithValue("@customerid", TextBox1.Text) '..TextBox2.Text)
command.Parameters.AddWithValue("@employeeid", TextBox2.Text) ''TextBox3.Text) 'search_value(TextBox3))
command.Parameters.AddWithValue("@shipvia", TextBox3.Text)
connection.Open()
If command.ExecuteNonQuery() = 1 Then
End If
End Using
End Using
Using connection As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True")
For rows = 0 To 8 ' grid(row, col)
For col = 0 To 4
Using command As New SqlCommand("insert into Pur_OrderDetail(orderId,ProductId,unitprice,Quantity,Discount) values(@orderId,@ProductId,@unitprice,@Quantity,@Discount)", connection)
col = 0
command.Parameters.AddWithValue("@orderId", TextBox4.Text) '.Text) 'TextBox5.Text)
col = col + 1
command.Parameters.AddWithValue("@ProductId", TextBox5.Text) 'Label12.Text) 'search_value("select ProductID from Products where ProductName =@TBox", TextBox6)) '..TextBox2.Text)
col = col + 1
command.Parameters.AddWithValue("@unitprice", TextBox6.Text) 'TextBox3.Text) 'search_value(TextBox3))
col = col + 1
command.Parameters.AddWithValue("@Quantity", TextBox7.Text) 'TextBox5.Text)
col = col + 1
command.Parameters.AddWithValue("@Discount", TextBox8.Text)
col = 0
rows = rows + 1
connection.Open()
If command.ExecuteNonQuery() = 1 Then
End If
connection.Close()
End Using
Next
Next
End Using
Using connection As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True")
For rows = 0 To ListView1.Items.Count - 1
Using command As New SqlCommand("UPDATE Product SET Stock = @stock WHERE ProductID = " & textbox9.text, connection)
command.Parameters.AddWithValue("@stock", textbox10.text)
connection.Open()
If command.ExecuteNonQuery() = 1 Then
End If
connection.Close()
End Using
End Sub


MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

Continue reading...
 
Back
Top