Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Storing the result of a Select Statement in a variable in Visual Studio C#

Options
  • 25-05-2009 5:20pm
    #1
    Registered Users Posts: 325 ✭✭


    Hi,

    I am trying to store a single value result in a variable in C# from a select statement to an access database....i want to do it if possible without using datasets and data adapter etc. the code below runs but keeps returning the value 0 when it should be 1....would be great if anyone could help to see if there are any errors.....

    OleDbConnection smb = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\SortmyBooks\\wineanddine.QVT;Persist Security Info=True;");

    smb.Open();
    OleDbCommand cmd5 = new OleDbCommand("SELECT CUS_ID From Invoices",smb);

    int answer = cmd5.ExecuteNonQuery();
    txtAmount.Text = answer.ToString();
    smb.Close();


    Thanks.


Comments

Advertisement