table binding ??

Nerine

Member
Joined
Nov 24, 2005
Messages
13
Location
Nede..Expel...???
Programming Experience
1-3
my question is how to binding textbox to dataset?

VB.NET:
Dim Connection As New OleDb.OleDbConnection
Dim DAExample As New OleDb.OleDbDataAdapter
Dim DSExample As New DataSet("DSExample")
 
Connection.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\Example.mdb"
Dim SelectCommand As New OleDb.OleDbCommand("SELECT * FROM Example WHERE Name LIKE '%' + @Name + '%'")
Dim SelectParameter As OleDb.OleDbParameter = SelectCommand.CreateParameter
SelectParameter.ParameterName = "@Name"
SelectParameter.Value = TxtSearch.Text
SelectCommand.Parameters.Add(SelectParameter)
DAExample.SelectCommand = SelectCommand
DAExample.SelectCommand.Connection = Connection
DSExample.Clear()
DAExample.Fill(DSMember, "Member")
Data_Binding()
 
Private Sub Data_Binding()
TxtName.DataBindings.Add("TEXT", DSExample, "Name")
TxtID.DataBindings.Add("TEXT", DSExample, "ID")
End Sub

with this code it will show exception say that can't bind to datasource!!

if i use

VB.NET:
TxtName.DataBindings.Add("Text", DSExample.Tables(0), "Name")

it will just show first result..
i need it to able to show all search result when i click the Next and Previous button....:confused:


p/s : Pls Correct Me If I Post On Wrong Section !!
 
Ok, firstly you cant bind to a dataset, remember, it's the datatable that stores the information. That is why your first section of code throws an exception. As for the second bit what do you mean when you say you want to show ALL results when clicking Prev/Next?
 
Nerine said:
i need it to able to show all search result when i click the Next and Previous button
I suggest that you take a look at the help/MSDN topic for the CurrencyManager class. It has a code sample of exactly what you want.
 
Back
Top