Display a on the datagrid [modified]
-
Hi.i did a project a that records a transactions that customer make daily something like Bank,so i want to display only transactions that were made by a specific customer using his account number on the datagrid.the problem is it doesn't display the record i that requested it to display only so i did something like this. public bool DisplayTrans(string CBarcode2) { try { conn1= new SqlConnection(ConString); cmdDisplay1= new SqlCommand(); daDisplay = new SqlDataAdapter(); dsDisplay = new DataSet(); cmdDisplay1.Connection = conn1; daDisplay.SelectCommand = cmdDisplay1; cmdDisplay1.CommandText = "SELECT CustomerName,ProductName,Price,EventName,BoughtDate,BoughtTime FROM Transactions WHERE Barcode2 =@Barcode2 "; SqlParameter Bar = new SqlParameter(); Bar.ParameterName = "@Barcode2"; Bar.Direction = System.Data.ParameterDirection.Input; Bar.Value = CBarcode2; cmdDisplay1.Parameters.Add(Bar); daDisplay.Fill(dsDisplay,"Transactions"); } catch(Exception ex) { MessageBox.Show(ex.Message); return false; } return true; -- modified at 5:31 Thursday 24th August, 2006
-
Hi.i did a project a that records a transactions that customer make daily something like Bank,so i want to display only transactions that were made by a specific customer using his account number on the datagrid.the problem is it doesn't display the record i that requested it to display only so i did something like this. public bool DisplayTrans(string CBarcode2) { try { conn1= new SqlConnection(ConString); cmdDisplay1= new SqlCommand(); daDisplay = new SqlDataAdapter(); dsDisplay = new DataSet(); cmdDisplay1.Connection = conn1; daDisplay.SelectCommand = cmdDisplay1; cmdDisplay1.CommandText = "SELECT CustomerName,ProductName,Price,EventName,BoughtDate,BoughtTime FROM Transactions WHERE Barcode2 =@Barcode2 "; SqlParameter Bar = new SqlParameter(); Bar.ParameterName = "@Barcode2"; Bar.Direction = System.Data.ParameterDirection.Input; Bar.Value = CBarcode2; cmdDisplay1.Parameters.Add(Bar); daDisplay.Fill(dsDisplay,"Transactions"); } catch(Exception ex) { MessageBox.Show(ex.Message); return false; } return true; -- modified at 5:31 Thursday 24th August, 2006
I assume that you have a problem with this code, and you're not just sharing it for fun ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
I assume that you have a problem with this code, and you're not just sharing it for fun ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Actually this is quite useful. I've been awake all night try to figure out how to how query the database and fill a dataset. I could have gotten more sleep if I'd have only waited for this post. :doh: ;P
only two letters away from being an asset
-
Actually this is quite useful. I've been awake all night try to figure out how to how query the database and fill a dataset. I could have gotten more sleep if I'd have only waited for this post. :doh: ;P
only two letters away from being an asset
hey, try this link Using DataGrid