Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to execut an SQL statement using BindingNavigator
 

How to execut an SQL statement using BindingNavigator

Hello

suppose we have some text boxes already binded with BindingNavigator how to execute an SQL query using the code so the binded data can be specified with this SQL statement

Sculptor  Saturday, January 13, 2007 2:23 PM
i mean i dont want to use the manual filter, want even deletinng, updating .. so on to be done with sql statements
Sculptor  Saturday, January 13, 2007 10:18 PM
yes you can. what I have try is add a datagridview, three textbox, one navigatorbar to the form,
I set Dataconnecion to sql server by IDE so it generate follow dataset, bindingsource and Tableadapter for me
private TestDataSet2 testDataSet2;
private System.Windows.Forms.BindingSource tBIDBindingSource;
private __11.TestDataSet2TableAdapters.TB_IDTableAdapter tB_IDTableAdapter;
I add follow at the form load event
this.tB_IDTableAdapter.Fill(this.testDataSet2.TB_ID);
this.bindingNavigator1.BindingSource = this.tBIDBindingSource;
this.textBox1.DataBindings.Add("Text", this.tBIDBindingSource, "ID", true, DataSourceUpdateMode.OnPropertyChanged);
this.textBox2.DataBindings.Add("Text", this.tBIDBindingSource, "Name", true, DataSourceUpdateMode.OnPropertyChanged);
this.textBox3.DataBindings.Add("Text", this.tBIDBindingSource, "Cost", true, DataSourceUpdateMode.OnPropertyChanged);
then all controls bind to same bindingsource
and at last if you want your operation save back to sql server , you need to add
this.tB_IDTableAdapter.Update(this.testDataSet2);
to where your operation is end
Bob zhu - SJTU  Thursday, January 18, 2007 4:05 AM

You can use google to search for other answers

Custom Search

More Threads

• Hiding properties in a .NET 1.1 Datagrid
• validate DataGrid bound to Array
• events keep on occuring
• Hierarchical DataGrid
• DataBinding PropertyChanged not working
• How do i display a messagebox after the loading of MainWindowForm?
• How to assign and retrieve the DataGridView.CheckBox value ?
• How can I mask a password column displayed with "*" in datagrid v. c++
• Bound Datagrid, but want to add a drop down with elements from another table
• DataGridView Filter on Children