b/s版的sql server查询分析器[susue提供]

应朋友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

posted on 2005-03-02 09:51  №阿儒№  阅读(2721)  评论(17编辑  收藏  举报