int myVariable = 0;
using (SqlConnection sqlConn = new SqlConnection("connString"))
using (SqlCommand cmd = new SqlCommand(@"SELECT MAX(MyColumnName) FROM MyTable", sqlConn))
using (SqlDataReader reader = cmd.ExecuteReader())
if (reader.GetValue(0) != DBNull.Value)
myVariable = (int)reader;
I hope you didnt use the exact code I pasted?!
You have to change the Sql query (to suit your dataBase design) and you have to use your connection string while creating a new reference of SqlConnection class.
And one more thing: I boxes the retreived value to integer. Is the column type of integer? If not, change to the right one.
If this is not it, please tell me what the error is!
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.