DataNavigator problem
Hello,
I have a function that retrieves a dataset from a stored procedure to a form. My problem is that the dataset has more than one records and i only get the first one at the form. I tried adding a dataNavigator but it doesn't seems to work.
Any suggestions?
Thank you.
Kirtan PatelPosted Aug 24, 2009, 11:46 AM
Here i have Corrected your code .
dont Add BindingNavigator Programatically Just Drag Drop One From ToolBox to your Form .
and Follow the Corrected Code :)
if still having Problem After using these code Send me your (All Project Folder+Database) in Zip to
[email protected] :)
private void select_items(string ID)
{
string connectionString = GetConnection();
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("SELECT_ITEMS",conn)
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@ID",ID));
conn.Open();
//Fill The DataTable From Command
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
//Set It To Binding Navigator
BindingSource itmBindSource = new BindingSource();
itmBindSource.DataSource = dt;
BindingNavigator1.BindingSource = itmBindSource;
area_code_combo.DataBindings.Add(new Binding("SelectedValue", itmBindSource, "AREA_CODE", true));
item_id_txt.DataBindings.Add(new Binding("Text", itmBindSource, "ITEM_ID", true));
product_descr.DataBindings.Add(new Binding("Text", itmBindSource, "ITEM_DESCR", true));
memo_txt.DataBindings.Add(new Binding("Text", itmtBindSource, "COMMENTS", true));
}
}
DealyPosted Aug 24, 2009, 1:37 PM
Kirtan PatelPosted Aug 24, 2009, 1:15 PM
Rectified your Problem in Code dear I just Removed 2 Lines From the Code you Sent me and problem Solved :)
Here is Your Corrected Northwind Sample Take a Look At it and Enjoy :)
I commented The Code Take a look at it .
also take Care that you search only those IDs that are Available in Database :)
Download your corrected Northwind Sample Code
DealyPosted Aug 24, 2009, 12:35 PM
DealyPosted Aug 24, 2009, 11:07 AM
Kirtan PatelPosted Aug 24, 2009, 10:37 AM
1. Post The code you are using to Get The Data From the database
2. Where you retrieving the data in DataGridView Or What ?
3.What Store Procedure Code You are using to Retrieve the Data ?
tell Me all Above information i Will Resolve your Problem :)
Happy Coding :)