Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid - Drop Down - Combo - Code - OLE DB

Status
Not open for further replies.

Isadore

Technical User
Feb 3, 2002
2,167
US
I am quickly learning with .NET that a "snippet" of code can make the difference between 15 minutes and 15 hours...

I am using a JET 4 OLEDB connection to Access, programming in Visual Basic...what few successes I have, I will try and post for those who embrace time as much as I do...

TOPIC: Changing a Recordset in a DataGrid using a Drop down or Combo box...

SETUP: Connection, DataAdapter and DataSet dragged to the form in Visual Basic Studio....

Code placed in the SelectedIndexChanged Event...

OBJECTS:

OLEDB Connection: OleDbConnection1
DataAdapter object: OleDbDataAdapter1
DataSet: DsGrpSummary
Drop down box: ddWID

...and we're off...

Dim MyWShedCommand As String
MyWShedCommand = "SELECT * from " & "tblGrpSummary WHERE " & "WatershedID ='" & ddWID.SelectedItem.Value & "'"
Dim cmdWShed As New OleDbCommand(MyWShedCommand, OleDbConnection1)

OleDbDataAdapter1.SelectCommand = cmdWShed
DsGrpSummary.Clear()
OleDbDataAdapter1.Fill(DsGrpSummary)
DataGrid1.DataBind()


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top