使用C#使用ASP.NET创建SQL脚本 [英] Creating sql script with asp.net using C#
问题描述
大家好,
我有一个网页作为configuration.aspx,并且在projet中有sample.sql数据库脚本.
在configuration.aspx页面中,我将测试箱作为服务器名,数据库名,AuthenticationMode,SQLUid,SQLPassword.
和一个按钮Submit.
现在,我必须在按钮单击事件上动态运行sql脚本.
请让我知道该怎么做.
Mohammad Wasif
Hi All,
I have a web page as configuration.aspx and have sample.sql database script in my projet.
in configuration.aspx page i have testbox as servername,databasename,AuthenticationMode,SQLUid,SQLPassword.
and a Button Submit.
Now I have to run sql script dynamically on button click event.
Please let me know how to do it.
Mohammad Wasif
推荐答案
^ ]
希望以上信息对您有所帮助.如果您还有其他顾虑,请告诉我.
http://www.google.com/#sclient=psy&hl=en&q=run+sql+script+on+button+click+event&aq=f&aqi=&aql=&oq=&psj=1&bav=on.2,or.&fp=cd65a9facc26f8d0[^]
I hope the above information will be helpful. If you have more concerns, please let me know.
我不确定我是否理解您的问题,但您的表格应如下所示:
I''m not sure I understood your question, but your form should look like:
<input name="nome" type="text" />
...
...
<input name="submit" type="submit" class="submit" value="submit" />
然后是处理数据的代码:
and then the code to process the data:
if (submit == "submit")
{
string name = "";
....
name = Request.QueryString["nome"];
....
and then the sql processing
string query = "........'',''" + name + "'')";
SqlCommand cmd = new SqlCommand(query, Conn);
cmd.ExecuteNonQuery();
}
当然,您应该适应自己的需求.
还有其他从表单中检索数据的方法,但这取决于您使用的是纯HTML还是.net控件.
对于asp.net控件,请参见此处:
http://msdn.microsoft .com/en-us/library/system.web.ui.webcontrols.button.click(v = VS.90).aspx [
Of course you should adapt to your needs.
There are other ways to retrieve data from forms, but that depends if you are using pure html or .net controls.
For asp.net controls see here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.click(v=VS.90).aspx[^]
读取文本字符串中的.sql文件
使用服务器名,数据库名,AuthenticationMode,SQLUid,SQLPassword生成连接字符串.
使用ADO.NET执行脚本.
这对您有帮助吗?
read .sql file in text string
generate connection strings using the servername,databasename,AuthenticationMode,SQLUid,SQLPassword.
use ADO.NET to execute the script.
does this help or you want code?
这篇关于使用C#使用ASP.NET创建SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!