Try this...trying to make it easy on you
I have typical advise for new programmers, it's how I started. The dataform wizard will write the basic code for a forms underlying functions - select, add. edit and delete.
Load, Add, Update, and Delete commands can get sticky really fast. The dataform wizard does a good job creating these commands for you. If you create a form with the dataform wizard and display the table in a grid, the wizard will generate code for Load, Add, Update, and Delete.
It will create code on button events for triggering the events.
I started by letting the wizard generate the code and dataadapters/datasets for me then tweeking the code the way I like it.
I delete OLEDBAdapter and replace with SQLDataAdapter for instance. The code for the Load button remains the same, I just have to change the DataSet, DataAdapter, and Connection Names.
1. drag an SqlDataAdapter onto a form
2. Choose a connection
3. Choose USE SQL STATEMENTS
4. Hit the Query Builder button
5. Add the Software Table
6. Check all the fields seperately
7. In the Criteria column of the ID field put =@orderid
8. finish out the Query wizard
The select statement and all other statements are created. Look at the generated code and use it until you become more familiar with the syntax. Expand + Windows Form Designer generated code and check out the select statement. then you can...
add this code before the try on the btnLoad.Click event
SqlSelectCommand1.Parameters("@orderid ").Value = OrderNo
example of wizard generated code:
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Try
Me.LoadDataSet()
Catch eLoad As System.Exception
System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
End Sub
Public Sub LoadDataSet()
Dim objDataSetTemp As WindowsApplication2.dsSoftware1
objDataSetTemp = New WindowsApplication2.dsSoftware1
Try
Me.FillDataSet(objDataSetTemp)
Catch eFillDataSet As System.Exception
Throw eFillDataSet
End Try
Try
grdSoftware.DataSource = Nothing
objdsSoftware1.Clear()
objdsSoftware1.Merge(objDataSetTemp)
grdSoftware.SetDataBinding(objdsSoftware1, "Software")
Catch eLoadMerge As System.Exception
Throw eLoadMerge
End Try
End Sub
Public Sub FillDataSet(ByVal dataSet As WindowsApplication2.dsSoftware1)
dataSet.EnforceConstraints = False
Try
Me.OleDbConnection1.Open()
Me.OleDbDataAdapter1.Fill(dataSet)
Catch fillException As System.Exception
Throw fillException
Finally
dataSet.EnforceConstraints = True
Me.OleDbConnection1.Close()
End Try
End Sub
You should be able to change OleDB to SQL and objdsSoftware1 to dsSoftware1 and take off running.
Let me know if it helps...