开发者

Problem with filling dataset

开发者 https://www.devze.com 2022-12-19 05:34 出处:网络
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 prese

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(Q开发者_运维知识库ueryNew, db);
NewCmd.Parameters.Add("@daynumber", SqlDbType.Int).Value = daynumber;
SqlDataAdapter NewDA = new SqlDataAdapter(NewCmd);
DataSet NewDS = new DataSet();
NewDA.Fill(NewDS);


Have you also verified that daynumber an int in the database? The exception thrown should give you more details about the error.


Where you tried NewDA.Fill(NewDS); Instead of it, try NewDA.Fill(NewDS,"<table_name>");

If your table name is ACTIVITY, then try NewDA.Fill(NewDS,"ACTIVITY");

0

精彩评论

暂无评论...
验证码 换一张
取 消