應朋友susue要求,將其剛入門的新作發布,也供大家分享一下~順便希望大家能給個意見~謝謝~運行效果如:
要有.net架構才能用
很膚淺,不到50行代碼
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<script runat="server" language="c#">
string strConnection; //串連sql server的字串
SqlCommand objCommand; //sql語句
void btnSelect_OnClick(object sender,EventArgs e)
{
strConnection = "server='" + tbxServer.Text + "';uid='" + tbxUid.Text + "';pwd='" + tbxPwd.Text + "';database='" + tbxDatabase.Text + "'";
SqlConnection objConnection=new SqlConnection(strConnection);
objCommand = new SqlCommand(tbxSql.Text,objConnection);
objConnection.Open();
dgrdMain.DataSource = objCommand.ExecuteReader();
//dgrdMain就是下面的DATAGRID的ID
dgrdMain.DataBind();
objConnection.Close();
}
</script>
<html>
<head>
<title>B/S版的Sql Server查詢分析器 By Susue 2005-2-26</title>
</head>
<body>
<font color="#dd0000" size="5">
B/S版的Sql Server查詢分析器 By Susue 2005-2-26
<hr>
</font>
<form runat="server">
<asp:Label Text="資料庫伺服器:" id="lbl1" Width="150" runat="server"/>
<asp:Label Text="使用者名稱:" id="lbl2" Width="150" runat="server"/>
<asp:Label Text="口令:" id="lbl3" Width="150" runat="server"/>
<asp:Label Text="資料庫名:" id="lbl4" runat="server"/><br>
<asp:TextBox Text="Server" id="tbxServer" runat="server"/>
<asp:TextBox Text="Uid" id="tbxUid" runat="server"/>
<asp:TextBox Text="Pwd" id="tbxPwd" runat="server"/>
<asp:TextBox Text="Database" id="tbxDatabase" runat="server"/><br>
<asp:TextBox Text="--這裡可以輸入SQL語句,每次只能執行一句" id="tbxSql" Width="633px" Rows="6" TextMode="MultiLine" runat="server"/><br>
<asp:Button Text=" 執 行 查 詢 " OnClick="btnSelect_OnClick" id="btnSelect" Width="633" runat="server"/><br><br>
<asp:DataGrid id="dgrdMain" cellpadding="1" showheader="true" borderwidth="1" runat="server"/>
</form>
<HR>
<font color="#dd0000" size="5">
B/S版的Sql Server查詢分析器 By Susue 2005-2-26
</font>
</body>
</html >
http://www.chinaaspx.com/comm/dotnetbbs/Showtopic.aspx?Forum_ID=5&Id=117612&PPage=1