Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Mindcracker Member - Abhijit barua
LATEST ACTIVITIES ARTICLESBLOGSFORUMSNEWSRESOURCESDOWNLOADSINTERVIEWSVIDEOS
 Abhijit barua
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
Contributions
Articles (0)
Blogs (7)
Forum Posts (9)
Downloads (0)
Book Chapters (0)
News & Resources (0)
Tutorials (0)
Photos (0)
Videos (0)
Interview Questions (0)



 PROFILE
Country:
Expertise:
 My Prizes  
No Prize Found
 PHOTO GALLERY  
No photo available
 FRIENDS LIST  
0 Friends
 MY FOLLOWERS 
No follower at the moment
 FOLLOWING 
Not following anyone
Featured E-book
Browse more books here»
This section is sponsored by
Nevron Gauge for SharePoint

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.