通过asp.net执行sql quries c# [英] execute sql quries by asp.net c#

查看:139
本文介绍了通过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

推荐答案

UDTWS写道:

是否有使用asp创建表和sp的任何进程.net编码用c#

is there any process to create tables and sp using asp.net coding with c#



是的,它是。


Yes, it is.

UDTWS写道:

只举一个例子来创建表语句来使用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();
  }
}


这篇关于通过asp.net执行sql quries c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆