| |

VerySource

 Forgot password?
 Register
Search
View: 580|Reply: 2

Operation database problems! Primary question, please advise

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-11 13:30:01
| Show all posts |Read mode
Find eligible records from the database and update!
Why does the old error "Dynamic SQL generation of UpdateCommand not supported for SelectCommand that does not return any key column information."?

How to modify it, I just learned ASP.net, please take care

string m_sql = "select * from item where id = 2277";
Ranch
SqlConnection sqlConnection1 = new SqlConnection (strConn);
SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter (m_sql, sqlConnection1) ;;
DataSet dataset = new DataSet ();
SqlCommandBuilder sqlcommandbuilder = new SqlCommandBuilder (sqlDataAdapter1);
Ranch
sqlConnection1.Open ();
sqlDataAdapter1.Fill (dataset, "ly");
sqlConnection1.Close ();
if (dataset.Tables [0] .Rows [0] ["item_serial"]. ToString () == "048")
{
Label1.Text = "Yes";
dataset.Tables [0] .Rows [0] ["item_serial"] = "hello"
sqlDataAdapter1.Update (dataset, "ly");
}
else
{
Label1.Text = "NO";
}
Reply

Use magic Report

0

Threads

29

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-4-6 22:30:01
| Show all posts
Does the item table have a primary key?
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-4-7 12:45:01
| Show all posts
Ok thanks
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list