Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Posted
Comments
[no name] 12-Oct-14 6:42am    
And why were you not able to find this yourself? http://www.w3schools.com/sql/sql_create_table.asp
Maciej Los 12-Oct-14 12:12pm    
Single user or multiple user framework?
UDTWS 12-Oct-14 23:03pm    
Thanks to reply but Mr.Wes Aday please understand my question first
[no name] 14-Oct-14 6:10am    
Please ask a question first. Thank you.

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

Yes, it is.
UDTWS wrote:
just give one example to create table statement to create table using asp.net with c#

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%.
 
Share this answer
 
Comments
UDTWS 12-Oct-14 23:06pm    
Thanks for reply and ya i know it but i just do it once to create database after that that page will be removed from server. plz tell me if any process thanks & regards
Maciej Los 13-Oct-14 1:49am    
I think the Visual Studio database project might help you here.
Can you take a look at my article here^
 
Share this answer
 
v3
C#
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();
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900