第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

請問C#連接數(shù)據(jù)庫報(bào)錯(cuò),“=”附近有語法,該怎么解決?

請問C#連接數(shù)據(jù)庫報(bào)錯(cuò),“=”附近有語法,該怎么解決?

慕斯王 2021-12-02 11:07:39
DataSet ds;DataRow dr;string newsid;void Page_Load(Object sender, EventArgs e){SqlConnection MyConnection;string ConnStr, strCon;newsid = Request.Params["id"]; MyConnection = new SqlConnection("server=ADMIN-PC;database=news;uid=sa;pwd='123456'");MyConnection.Open();string strCom = "Select biaoti,zhaizi,neirong,img,counter,shijian from news where id=" + newsid;ds = new DataSet();SqlDataAdapter myCommand = new SqlDataAdapter(strCom, MyConnection);myCommand.Fill(ds, "news");dr = ds.Tables["news"].Rows[0];strCon = "Select counter from news where id=" + newsid;SqlCommand mycommand2 = new SqlCommand(strCon, MyConnection);SqlDataReader reader = mycommand2.ExecuteReader();reader.Read();int i = reader.GetInt32(0);i++;reader.Close(); strCon = "Update news set counter=" + i.ToString() + "where (id=" + newsid + ")";mycommand2.CommandText = strCon;mycommand2.ExecuteNonQuery(); MyConnection.Close(); }
查看完整描述

2 回答

?
阿波羅的戰(zhàn)車

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊

這個(gè)肯定是SQL語句的錯(cuò)誤
Select biaoti,zhaizi,neirong,img,counter,shijian from news where id=' "+ newsid+"'
Select counter from news where id=' "+ newsid+"'
Update news set counter=" + i.ToString() + "where (id=" + newsid + ")
前兩條錯(cuò)了 在sql2005修改后之后通過

查看完整回答
反對 回復(fù) 2021-12-06
?
蝴蝶不菲

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊

strCon = "Update news set counter=" + i.ToString() + "where (id=" + newsid + ")";
在where前加一個(gè)空格

查看完整回答
反對 回復(fù) 2021-12-06
  • 2 回答
  • 0 關(guān)注
  • 644 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)