Getting a value out of stored procedure.

    Date: 09/06/06 (C Sharp)    Keywords: sql

    Hi guys, me again.

    Here's a stored procedure procedure

    [SqlProcedure]
    public static void GetLastAddressId()
    {
    string sqlString = "SELECT MAX(ADRID) FROM dbo.tblAddress";

    SqlPipe sp = SqlContext.Pipe;
    using (SqlConnection conn = new SqlConnection("context connection=true"))
    {
    conn.Open();
    SqlCommand cmd = new SqlCommand();
    cmd.CommandType = CommandType.Text;
    cmd.Connection = conn;
    cmd.CommandText = sqlString;
    string rdr = cmd.ExecuteScalar().ToString();
    sp.Send(rdr);
    }
    }


    Then, there is a TableAdapter with query which is set to return a Single Value.

    Then, here is a place where I use that TableAdapter to get that maximum Id (inside some class):

    public static string getLastAddressId()
    {
    DALTableAdapters.QueriesTableAdapter fs
    = new DALTableAdapters.QueriesTableAdapter();

    return (fs.GetLastAddressId()).ToString();
    }


    Why does the last line (the "return" line) give me an exception, saying that the referenced object doesn't exist? I'm sure I did something wrong with the stored procedure, as I never figured out how to send values like that from stored procedure to my program. Please, help.

    Source: http://community.livejournal.com/csharp/75471.html

« XNA Studio Express (Beta)... || JetBrains dotTrace 2.0 beta... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home