通过asp.net执行sql quries c#
我的要求是我在服务器上没有工具来创建数据库和表,而sp在服务器上运行。现在我需要帮助是否有任何进程来创建表和sp使用asp.net编码与c#只是举一个例子创建表语句来创建表使用asp.net与c#。
谢谢和问候
hi my requirement is that i have no tool on server to create database and tables and sp to run on server. now i need help is there any process to create tables and sp using asp.net coding with c# just give one example to create table statement to create table using asp.net with c#.
Thanks & Regards
是否有使用asp创建表和sp的任何进程.net编码用c#
is there any process to create tables and sp using asp.net coding with c#
是的,它是。
Yes, it is.
只举一个例子来创建表语句来使用asp.net创建表c#
just give one example to create table statement to create table using asp.net with c#
不,因为它是 dangerous 大>想法。当Web应用程序可以发送和运行任何sql命令时,存在 SQL的风险注入 [ ^ ]可能等于1000%。
No, because it's dangerous idea. When the web application can send and run any sql command, the risk of SQL injection[^] is probably equal to 1000%.
我认为Visual Studio数据库项目可能对你有所帮助。
你能看看吗在我的文章 这里^
I think the Visual Studio database project might help you here.
Can you take a look at my article here^
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);
public void create()
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd = new SqlCommand("create table tbl_table(id int Identity(1,1) primary key, newtext varchar(100) )", con);
cmd.ExecuteNonQuery();
if (con.State == ConnectionState.Open)
{
con.Close();
}
}