execute non-query returns the number of rows affected by the non-query 
statement ie the number of rows updated, inserted or deleted.  You need execute 
scalar for one row or execute reader for multiple rows.  You'll have to follow 
that with a reader.read() to cycle the rows or hasrows to check for rows 
returned.
 
HTH
 
Dwayne

Michael Swanson <[EMAIL PROTECTED]> wrote: 
Hi,
Yes, I have checked the Query Analizer and the stored procedure 
returns the results I am looking for. I can also change my code 
somewhat to use a data adapter with a dataset and use the query that 
I have been using as the data adapters select command. I can fill 
the dataset and show my results in a datagrid. However when I am 
just using a straight sqlcommand to set up the query as normal, open 
the connection, run the query, then close the connection, I keep 
getting back a -1. I can not understand what is happening that will 
make it not return the expected results. Once again for you to 
view, here is the low down of the command:

SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlConnection1;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@CName", SqlDbType.VarChar, 
50));
cmd.Parameters["@CName"].Value = txtNewCharName.Text;
cmd.CommandText = "spCheckIfCharExists";
sqlConnection1.Open();
lblRegister.Text = cmd.ExecuteNonQuery().ToString();
sqlConnection1.Close();

If anyone could please help me figure out what is happening I would 
truely appreciate it. Thank you!







Yahoo! Groups Links









[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to