SIGN UP MEMBER LOGIN:    

Abhijit barua

Born on October 15Member since Jan 21, 2012 India
Points: 49
Total Visits: 163
Read Count: 11,395 Liked: 0
Abhijit barua's Image

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
No all activity at the moment
No my activity at the moment
No friends activity at the moment
Member Popularity
MY FRIENDS
No friends at the moment
Community Activity
MY PHOTO
No photo's at the moment
Top Ranked
MY FOLLOWERS
No follower at the moment
I'M FOLLOWING
No following at the moment