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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

提問c# 相關(guān)問題:連接SQL數(shù)據(jù)庫代碼出錯?。??

C# C
楊魅力 2021-12-02 11:07:46

我在useing窗體的load事件寫了      private void useing_Load(object sender, EventArgs e)        {            string strConnection = " Data Source=PC-20090625HIOS\SQLEXPRESS;Initial Catalog=student;Integrated Security=True";             SqlConnection objConnection = new SqlConnection(strConnection);            objConnection.Open();            string strcommand = "select * from record";            SqlCommand objcommand = new SqlCommand(strcommand, objConnection);           this.textBox1 .Text =strcommand ;           objConnection.Close();        }想要把record數(shù)據(jù)庫里的數(shù)據(jù)調(diào)出來給textBox1但是好像不行!其中PC-20090625HIOS\SQLEXPRESS是我的SQL服務(wù)器名稱,我是用windows驗證的。但是編譯器說PC-20090625HIOS\SQLEXPRESS是“無法識別的轉(zhuǎn)義序列”。
查看完整描述

3 回答

?
江戶川亂折騰

TA貢獻1851條經(jīng)驗 獲得超5個贊

PC-20090625HIOS\SQLEXPRESS 中包含一個轉(zhuǎn)義字符"\",他會把之后的一個字符組合起來做轉(zhuǎn)義:\S
你用兩個斜杠試試.
PC-20090625HIOS\\SQLEXPRESS

查看完整回答
反對 回復(fù) 2021-12-06
?
aluckdog

TA貢獻1847條經(jīng)驗 獲得超7個贊

定義一個類,寫數(shù)據(jù)庫連接,執(zhí)行語句,讀取等方法,然后在要用的類里實例化一下,在調(diào)用就可以了,我用的是C#,你看看
class dosql
{
public OleDbConnection getcon()
{
string M_str_oledbcon = "連接字符串";
OleDbConnection myCon = new OleDbConnection(M_str_oledbcon);
return myCon;
}
public void getcom(string M_str_oledbstr)
{
OleDbConnection oledbcon = this.getcon();
oledbcon.Open();
OleDbCommand oledbcom = new OleDbCommand(M_str_oledbstr, oledbcon);
oledbcom.ExecuteNonQuery();
oledbcom.Dispose();
oledbcon.Close();
oledbcon.Dispose();
}
public DataSet getds(string M_str_oledbcstr, string M_str_table)
{
OleDbConnection oledbcon = this.getcon();
OleDbDataAdapter oledbda = new OleDbDataAdapter(M_str_oledbcstr, oledbcon);
DataSet myds = new DataSet();
oledbda.Fill(myds, M_str_table);
return myds;
}
public OleDbDataReader getread(string M_str_oledbstr)
{
OleDbConnection oledbcon = this.getcon();
OleDbCommand oledbcom = new OleDbCommand(M_str_oledbstr, oledbcon);
oledbcon.Open();
OleDbDataReader oledbread = oledbcom.ExecuteReader(CommandBehavior.CloseConnection);
return oledbread;

}
}
你對照VB的函數(shù)修改下


查看完整回答
反對 回復(fù) 2021-12-06
?
紅顏莎娜

TA貢獻1842條經(jīng)驗 獲得超13個贊

string strConnection = " Data Source=PC-20090625HIOS\SQLEXPRESS;Initial Catalog=student;Integrated Security=True"; 改為string strConnection = " Data Source=PC-20090625HIOS\\SQLEXPRESS;Initial Catalog=student;Integrated Security=True"; 或者string strConnection =@ " Data Source=PC-20090625HIOS\SQLEXPRESS;Initial Catalog=student;Integrated Security=True"; 試試看,不行的話你就用用戶加密碼的別用windows驗證

查看完整回答
反對 回復(fù) 2021-12-06
  • 3 回答
  • 0 關(guān)注
  • 283 瀏覽

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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