Tuesday, December 11, 2007

How to change your SQLcommand during runtime

How to change your SQLcommand during runtime

Step 1

To change your SQL statement during runtime, all you need to do is set certain parameter to your SQL statement

The code bellows shows that we have set OleDbSelectCommand.CommandText to Select * from Employee which is another table in your database.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Me.OleDbSelectCommand1.CommandText = "SELECT * from employee"

Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1

OleDbDataAdapter1.SelectCommand = OleDbSelectCommand1

OleDbDataAdapter1.Fill(DataSet11)

End Sub

Step 2

We need to create a button with the text Populate with Employee. Then double click on it to enter the code provided above.

No comments: