c 操作sql server2008 的介面

2021-07-28 11:57:21 字數 3664 閱讀 4894

先是查詢整張表,用到combobox選擇查詢哪張表,最後用datagridview顯示

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.windows.forms;

private void datagridview1_cellcontentclick(object sender, datagridviewcelleventargs e)

private void form1_load(object sender, eventargs e)

private void combobox1_selectedindexchanged(object sender, eventargs e)

datatable table = sqlmanage.tableselect(sql);

this.datagridview1.datasource = table;}}

}

然後是修改**,這個比較簡單,用到textbox和button

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.windows.forms;

private void button4_click(object sender, eventargs e)

private void button1_click(object sender, eventargs e)

','','')",

this.textbox1.text, this.textbox2.text, this.textbox3.text);

sqlmanage.tablechange(sql);

}private void button2_click(object sender, eventargs e)

','''','')",

this.textbox1.text, this.textbox2.text, this.textbox3.text);

sqlmanage.tablechange(sql);

}private void button3_click(object sender, eventargs e)

'",this.textbox1.text);

sqlmanage.tablechange(sql);

}private void form2_load(object sender, eventargs e)

}}

按條件查詢**,這個是核心,用到radiobutt,combobox,,button, datagridview

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.windows.forms;

private void datagridview1_cellcontentclick(object sender, datagridviewcelleventargs e)

private void form3_load(object sender, eventargs e)

if (table.rows.count > 0)

//初始化教師姓名

string sql_name = "select t_name from teacher";

table.clear();

table = sqlmanage.tableselect(sql_name);

string t_name;

foreach (datarow row in table.rows)

if (table.rows.count > 0)

//初始化學生

string sql_id = "select id from student";

table.clear();

table = sqlmanage.tableselect(sql_id);

string s_id;

foreach (datarow row in table.rows)

if (table.rows.count > 0)

//初始化學生

string sql_sname = "select name from student";

table.clear();

table = sqlmanage.tableselect(sql_sname);

string t_sname;

foreach (datarow row in table.rows)

if (table.rows.count > 0)

}private void button2_click(object sender, eventargs e)

private void button1_click(object sender, eventargs e)

'",this.combobox1.text);

}else if (this.radiobutton2.checked)

'",this.combobox2.text);

}else if (this.radiobutton3.checked)

'",this.combobox3.text);

}else if (this.radiobutton4.checked)

'",this.combobox4.text);

}datatable table = sqlmanage.tableselect(sql);

if (table.rows.count > 0)

else

}private void radiobutton1_checkedchanged(object sender, eventargs e)

else

}private void radiobutton2_checkedchanged(object sender, eventargs e)

else

}private void radiobutton3_checkedchanged(object sender, eventargs e)

else

}private void radiobutton4_checkedchanged(object sender, eventargs e)

else}}

}

sqlserver200 無法訪問

前幾天維護乙個老專案,用到了sqlserver2000,好老的資料庫啊,沒辦法啊 在另外一台機器上配置了環境,基本問題都修改完成了,但是在另外一台機器上,顯示器搬過來搬過去很不舒服,今天就在自己機器上配置一下環境 先說下環境 另外一天機器 xp sqlserver2000 sp4 我的機器 win7...

如何設定遠端訪問SQL Server2005

sql server2005不能進行遠端連線問題困擾了我好幾天,今天終於把這個問題給解決了!再這個過程中在網上我查詢了很多資料,發現有很多方法都不能很好的解決問題,我將其整理如下 首先檢視埠,看有沒1433 sql server的預設埠 1 執行 cmd netstat ano 看是否有 tcp 0...

如何設定遠端訪問SQL Server2005

sql server2005 不能進行遠端連線問題困擾了我好幾天,今天終於把這個問題給解決了!再這個過程中在網上我查詢了很多資料,發現有很多方法都不能很好的解決問題,我將其整理如下 首先檢視埠,看有沒 1433 sql server 的預設埠 1 執行 cmd netstat ano 看是否有 tc...