高清国产av一区二区三区_亚洲欧美日韩在线_无码熟妇人妻av在线影片免费_在线无码一级伊伊_爽好舒服高H自慰软件_亚洲熟女区偷拍区高清区_午夜福利影院啪啪_亚洲国产黄片在线播放_中文字幕日韩精品乐乐影院_久久国产亚洲日韩欧美精品

掃描二維碼關(guān)注

首頁(yè) APP開(kāi)發(fā)小程序開(kāi)發(fā) 微信公眾號(hào) 網(wǎng)站建設(shè) 營(yíng)銷(xiāo)推廣 經(jīng)典案列 產(chǎn)品服務(wù) 關(guān)于我們

“學(xué)習(xí)不僅是掌握知識(shí)”

向書(shū)本學(xué)習(xí),還要向?qū)嵺`學(xué)習(xí)、向生活學(xué)習(xí)。消化已有知識(shí),
而且要力求有所發(fā)現(xiàn)、有所發(fā)明、有所創(chuàng)造

.NET數(shù)據(jù)庫(kù)操作

2019/3/24 8:18:11

.NET數(shù)據(jù)庫(kù)操作

連接數(shù)據(jù)庫(kù)
源代碼:


private void Page_Load(object sender, System.EventArgs e)
{

myConnection = new SqlConnection("server=localhost;" +
"database=zhishi;uid=scm;pwd=scm");

//if (!IsPostBack) BindGrid();
}


查詢數(shù)據(jù)庫(kù)

源代碼:

public void BindGrid()
{

myConnection = new SqlConnection("server=localhost;" +
"database=zhishi;uid=scm;pwd=scm");

SqlDataAdapter myCommand = new SqlDataAdapter("SELECT top 10 * FROM" +
" wujml", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds);

MyDataGrid.DataSource=ds;
MyDataGrid.DataBind();

}


增刪改數(shù)據(jù)庫(kù)

源代碼:

 

public void AddAuthor_Click()
{


String insertCmd = "insert into wujml(wujid,wujbt,wujlj1) "+
"values ('99999','111','3131')";

SqlCommand myCommand = new SqlCommand(insertCmd, myConnection);
myCommand.Connection.Open();

try
{
myCommand.ExecuteNonQuery();
//Message.InnerHtml = "Record Added
" + insertCmd;

}

catch
{
//Console.WriteLine("{0} Second exception caught.", e);

this.body.Text = "*************";

}

myCommand.Connection.Close();


}

連接SQL Server數(shù)據(jù)庫(kù)

源代碼:

 

//作用: 連接SQL Server數(shù)據(jù)庫(kù)

//參數(shù):ServerName 服務(wù)器名,DBName 數(shù)據(jù)庫(kù)名,UserID 用戶名,UserPwd 用戶密碼

public void ConnSQLServer(string ServerName, string DBName)

{

mCnnDB.ConnectionString = "uid=;pwd= ;driver={SQL Server};" +

"server=" +ServerName+

";database=" + DBName;

mCnnDB.Open(mCnnDB.ConnectionString,"sa","",-1);

}

public void ConnSQLServer(string ServerName, string DBName,string UserID,string UserPwd)

{ mCnnDB.ConnectionString = "uid='" + UserID + "';pwd='" + UserPwd + "' ;driver={SQL Server};" +

"server=" + ServerName +

";database=" + DBName;

mCnnDB.Open(mCnnDB.ConnectionString,UserID,UserPwd,-1);;

}

連接ODBC數(shù)據(jù)庫(kù)

源代碼:

 

// '作用: 連接ODBC數(shù)據(jù)庫(kù)

// '參數(shù):dsnName ODBC名,UserID 用戶名,UserPwd 用戶密碼

public void ConnODBC(string dsnName )

{

mCnnDB.Provider = "MSDASQL";

mCnnDB.ConnectionString = "Data Source='" + dsnName + "'";

mCnnDB.Open(mCnnDB.ConnectionString,"","",-1);

}

public void ConnODBC(string dsnName,string UserID, string UserPwd )

{ mCnnDB.Provider = "MSDASQL";

mCnnDB.ConnectionString = "User ID='" +UserID + "';" +

"Password='" + UserPwd + "';" +

"Data Source='"+dsnName+ "'";

mCnnDB.Open(mCnnDB.ConnectionString,UserID,UserPwd,-1 );


 


深圳市南山區(qū)南山街道南海大道西桂廟路北陽(yáng)光華藝大廈1棟4F、4G-04

咨詢電話:136 8237 6272
大客戶咨詢:139 0290 5075
業(yè)務(wù)QQ:195006118
技術(shù)QQ:179981967

精銳軟件

Copyright? 2018-2023 深圳精銳軟件技術(shù)有限公司 All Rights Reserved. ICP備案號(hào):粵ICP備18108116號(hào)-8 公安備案號(hào):粵公網(wǎng)安備44030502009460號(hào)