|
|

|
Sql server database table from c#.net with variable table name.
When you have database and you have to create table with variable name.Then you can create like below. protected void Page_Load(object sender, EventArgs e) { } private string GetConnectionString() {
//sets the connection string from your web config file. "DBConnection" is the name of your Connection String
return System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
} public bool DeleteData(string TableName) {
SqlConnection connection = new SqlConnection(GetConnectionString()); connection.Open(); string sqlStatement = "CREATE TABLE " + TableName + "" + "(stuid INTEGER PRIMARY KEY," + "stuname CHAR(50), stuaddress CHAR(255),
stubalance FLOAT)"; SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection); sqlCmd.ExecuteNonQuery(); connection.Close(); &n
|
|
|
|
|
|
|
|
|
|
|
|