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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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

  • 25-05-2009 4:20pm
    #1
    Registered Users, Registered Users 2 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