且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用C#使用ASP.NET创建SQL脚本

更新时间:2023-01-23 12:45:06

^ ]

希望以上信息对您有所帮助.如果您还有其他顾虑,请告诉我.
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?