C# 2010 Data Designer adapter RRS feed

  • Question

  • This is probably an easy solution.  I have made a data adapter that points to a table called Edits.  In SQL, I have a query that takes 2 parameters and returns the ID of the table where results are desired.

    In the code snippet, I have the following:

    // Global level

    public MTMDSEditTableTableAdapters.EditsTableTableAdapter EditTableAdapter = new MTMDSEditTableTableAdapters.EditsTableTableAdapter();

    In main code where I want to call the data in, I have the following:

    MTMDSEditTableTableAdapters.EditsTableTableAdapter EditTable = new MTMDSEditTableTableAdapters.EditsTableTableAdapter();
    EditTable.sp_SelectEditByTypeAndFName(ControlTypeName, ControlFriendlyName);

    I know that I need to assign the query command to something, but not sure what to assign it to.  However, I want to process the data like so:

    if ( {MyDataReturned} != null && {MyDataReturned} > 0)
    // Process the data

    I expect to get only 1 field back, the ID and I am not putting it into a gridview or data table or data row.  Seems a little excessive to do so when all I need to do is process that one field value.

    So what should I assign it to?  It seems to only want to use an object data type.

    • Moved by CoolDadTx Monday, March 19, 2012 4:06 PM Not IDE related (From:Visual C# IDE)
    Monday, March 19, 2012 3:49 PM


  • I'd use SqlCommand (if you are dealing with SQL Server, otherwise an appropriate XYCommand) and its ExecuteScalar method in such case.

    Miha Markic [MVP C#]

    Tuesday, March 20, 2012 12:33 PM