Problem with filling dataset

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-02-07T20:45:29Z Indexed on 2010/04/19 2:03 UTC
Read the original article Hit count: 335

Filed under:
|
|
|

This is a small portion of my code file. Each time my debugger reaches the line 'NewDA.Fill(NewDS);' at runtime it jumps to the catch. I'm positive the daynumber variable gets a value that's present in the database and I've tried the query outside of the codefile on my database and it works fine. I'm also using the connectionstring 'db' on more parts of the code with successful results.

string QueryNew = "SELECT activityname AS [Name], activitycategorynumber AS [Category] " + 
                  "FROM ACTIVITY WHERE daynumber = @daynumber";

SqlCommand NewCmd = new SqlCommand(QueryNew, db);
NewCmd.Parameters.Add("@daynumber", SqlDbType.Int).Value = daynumber;
SqlDataAdapter NewDA = new SqlDataAdapter(NewCmd);
DataSet NewDS = new DataSet();
NewDA.Fill(NewDS);

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET