Tweet
SIGN UP
MEMBER LOGIN:
TECHNOLOGIES
.NET 4.5
.NET Remoting in C#
Active Directory C#
ADO.NET in C#
AJAX in C#
Algorithms in C#
Android Programming
Articles C#
ASP, JavaScript, CSS
ASP.NET Controls in C#
ASP.NET MVC with C#
ASP.NET Programming
BizTalk Server
C# Assemblies
C# Language
C# Tutorials
C, C++, MFC
Career Advice
Chapters
Cloud Computing
COBOL.NET
Coding Best Practices
COM Interop
Compact Framework
Cryptography C#
Crystal Reports C#
Current Affairs
Custom Controls C#
Databases & DBA
Deployment
Design & Architecture
DirectX C#
Enterprise Development
Error Zone
Exception Handling C#
Expression Studio
F#
Files, Directories in C#
Financial Applications
Games Programming C#
GDI+ & Graphics
Hardware
How do I
HTML 5
Internet & Web
iPhone/iPad
Java
Java and .NET
JQuery
JSP
Leadership
Learn .NET
LINQ with C#
Metro Style Apps in C#
Mobile & Embedded
MonoDevelop
MSMQ in C#
Multithreading in C#
Networking
Office Development
OOP/OOD
Operating Systems
PHP
Printing in C#
Products
Project Management
Reports using C#
Robotics & Hardware
Security in .NET
SharePoint
Silverlight with C#
Smart Devices
Speech in C#
SQL
SQL Server 2012
String in C#
Team Foundation & VSS
Testing
Visual Basic .NET
Visual C#
Visual Studio .NET
Visual Studio 11
Visual Studio 2010
VS LightSwitch 2011
WCF with C#
Web Forms C#
Web Services in C#
WebForms Controls
Windows 8 in C#
Windows Controls C#
Windows Forms C#
Windows Phone in C#
Windows PowerShell
Windows Services in C#
Workflow Foundation in C#
WPF with C#
XAML with C#
XML in C#
XNA with C#
FORUMS
BLOGS
VIDEOS
INTERVIEWS
CERTIFICATIONS
DOWNLOADS
BOOKS
LINKS
NEWS
Learn .NET in 60 days – Part 1 (13 Labs)
Learn MVC (Model view controller) Step by Step ...
Learn C# Corner - Home
Using Border Radius and Gradients in CSS3: Part I
Learn C# Corner - Footer
Learn .NET and C# in 60 Days Lab13(Day 5): - C ...
iPhone 5 First Look
Samsung Galaxy Note Review
WCF - Authentication and Authorization in Ente ...
How to write a good article on C# Corner
Blog
Create database table using c#.net with variable of table name
Posted by
Abhijit barua
in
Blogs
|
.NET 4.5
on
Jan 21, 2012
Create database table using c#.net with variable of table name
Tweet
1349
0
0
Here you can take table name as value from textbox, with that name you can create table at database.
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 + "" + "(studentid INTEGER PRIMARY KEY," + "stuname CHAR(50), stuaddress CHAR
(255), stubalance FLOAT)";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);
sqlCmd.ExecuteNonQuery();
connection.Close();
return true;
}
protected void Button1_Click(object sender, EventArgs e)
{
string a = TextBox1.Text;
DeleteData(a);
}
share this blog :
select query on datatable for ..
VS 2010 Keyboard Shortcut posters
Related Blogs
How to find All system tables in Sql Server database
How to Update Session Object in C#
How To create One or more Database Backup in Loop using Sql server Cursor
Visual Studio 11 not 2011
Create Dynamic Table With Given Row and Column Values from User Input
Querying the table result in XML format
post comment
Sponsored by
Become a Sponsor
More Blogs from this Blogger
Shopping cart add more, remove functionality using view state
Create dynamic accordion pane and bind with varbinary data
Select query on datatable for filter data
Binding ajax popup extender with database value.
Select Query on DataTable for filtering Data Using LINQ
Create database table using c#.net with variable of table name
GridView image popup using JQuery and asp.net
select query on datatable for filter data
View All
Latest Blogs
Free Ride is Over for Desktop Developers in Visual Studio 11
DotNet developers most used application/tools launching through 'Run'
80-inch Windows 8 Tablet
Data encapsulation
Option to access the Column Names in Data table
Open multiple windows in browser startup. (Multiple homepages option)
I'm Sorry
const and readonly
Address, Binding and Contract in WCF
JQuery Maxchars Plugin
View All
Sponsored by
Become a Sponsor