b001
asked on
clear data in a dataset table
Hi Experts
I have dataset DS filled with data form 2 tables tablename1,tablenameRef
Fmsadapter.Fill(dS, tableName)
REFadapter.Fill(dS, tableNameRef)
I would like to clear data of only one table called tablenameRef everytime I Keydown a textbox.
The following command clear all the data.
dS.Tables.Clear()
Please help
Thanks
I have dataset DS filled with data form 2 tables tablename1,tablenameRef
Fmsadapter.Fill(dS, tableName)
REFadapter.Fill(dS, tableNameRef)
I would like to clear data of only one table called tablenameRef everytime I Keydown a textbox.
The following command clear all the data.
dS.Tables.Clear()
Please help
Thanks
Hi b001;
The sample code will clear the Table tablenameRef of its data every time a key is pressed while TextBox1 has focus.
Fernando
The sample code will clear the Table tablenameRef of its data every time a key is pressed while TextBox1 has focus.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
ds.Tables("tablenameRef").Clear()
End Sub
Fernando
@ carl_tawn;
You need quotes around the table name.
You need quotes around the table name.
tableNameRef in the original posted is unqouted, which would suggest it is a variable rather than the name of the table itself, hence no quotes.
ASKER
tableNameRef is veraible.
I tried the following codes and I have error
dS.Tables(tableNameRef).Cl ear()
dS.Tables("tableNameRef"). Clear()
dS.Tables(" & tableNameRef & ").Clear()
eror:
Object reference not set to an instance of an object.
I tried the following codes and I have error
dS.Tables(tableNameRef).Cl
dS.Tables("tableNameRef").
dS.Tables(" & tableNameRef & ").Clear()
eror:
Object reference not set to an instance of an object.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi b001;
You can use a numeric index. For example if tableNameRef was loaded into the DataSet object as the second table then the code in the snippet will work. If it was the first table loaded then change (1) to (0) in the code snippet.
You can use a numeric index. For example if tableNameRef was loaded into the DataSet object as the second table then the code in the snippet will work. If it was the first table loaded then change (1) to (0) in the code snippet.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
ds.Tables(1).Clear()
End Sub
Open in new window