Hi there
I am trying to pass the id value of the selected row in a datagridview in one windows form to another windows form.
How is this done?
I have created a string and put the value of a certain column of the currentRow of the datagridview,
then parsed this string into an int, i know these two bits are working as ive put in Console.WriteLine s to check and the numbers outputted are correct,
I am then passing in this int value to the new object of the form I am trying to send it to, (I have now checked this using another Console.WriteLine and the number is successfully passed through),
then I am using this int value in the new form by passing it to a method in the database class, and asked this method to return a List<Product> object with all the details of the selected row of the datagridview of the first form,
I have declared a new List<Product> in the new form class and have assigned what the method in the database class returns
I have then done another Console.WriteLine to output this new List<Product>, but it doesnt output anything after the database method call(of which should fill it with stuff)
Two reasons I can think of are;
My SQL query in the database method is incorrect, or
you cant use Console.WriteLine to display the stuff in the List<Product> object
Part of our database method including the sql query is this;
Can anyone shed any light on this?
Many thanks
Jackie
I am trying to pass the id value of the selected row in a datagridview in one windows form to another windows form.
How is this done?
I have created a string and put the value of a certain column of the currentRow of the datagridview,
then parsed this string into an int, i know these two bits are working as ive put in Console.WriteLine s to check and the numbers outputted are correct,
I am then passing in this int value to the new object of the form I am trying to send it to, (I have now checked this using another Console.WriteLine and the number is successfully passed through),
then I am using this int value in the new form by passing it to a method in the database class, and asked this method to return a List<Product> object with all the details of the selected row of the datagridview of the first form,
I have declared a new List<Product> in the new form class and have assigned what the method in the database class returns
I have then done another Console.WriteLine to output this new List<Product>, but it doesnt output anything after the database method call(of which should fill it with stuff)
Two reasons I can think of are;
My SQL query in the database method is incorrect, or
you cant use Console.WriteLine to display the stuff in the List<Product> object
Part of our database method including the sql query is this;
C#:
public static List<Product> LoadProduct(int id)
{
List<Product> product = new List<Product>();
OleDbConnection myConnection = GetConnection();
string myQuery = String.Format("SELECT Product_ID, Product_Name, Product_Description, Price FROM Product where Product_ID = {0}", id);
OleDbCommand command = new OleDbCommand(myQuery, myConnection);
Can anyone shed any light on this?
Many thanks
Jackie