TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Desi Bravo
NA
25
0
C# Create multiple database programmatically
Mar 6 2012 10:11 AM
I followed a tutorial from Mahesh.
I created a windows application with a textbox and a button.
Textbox is used to enter the database name and click on the button to create the database.
The downside of it is that i can only create one database.
I normal code is from sql server the mdf file and the log file I had to enter it hard-coded but like to know how i can use textboxes to make those changes in order to create more than one database.
CreateDatabase = "CREATE DATABASE " + txtDatabase.Text + " ON PRIMARY " +
"(NAME = myDatabaseData," +
" FILENAME = 'C:\\Database\\txtDatabase.Text.mdf', " +
"SIZE = 3MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +
"LOG ON (NAME = txtDatabase_log, " +
"FILENAME = 'C:\\Database\\txtDatabase.Text.ldf', " +
"SIZE = 1MB, " +
"MAXSIZE = 5MB, " +
"FILEGROWTH = 10%)";
On the form i want to add another textbox for the FILENAME what i have illustrated is not working and not sure how to make it work.
CreateDatabase = "CREATE DATABASE " + txtDatabase.Text + " ON PRIMARY " +
"(NAME = myDatabaseData," +
" FILENAME = 'C:\\Database\\myDatabase.mdf', " +
"SIZE = 3MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +
"LOG ON (NAME = txtDatabase_log, " +
"FILENAME = 'C:\\Database\\myDatabase.ldf', " +
"SIZE = 1MB, " +
"MAXSIZE = 5MB, " +
"FILEGROWTH = 10%)";
By changing it as illustrated it works but only creates one database.
I want to create more than one database.
the user will be able to enter all the information in the textbox and click on the button to execute the code.
I appreciate for your assistance. Thanks in advance.
Reply
Answers (
2
)
Fragment Caching
Crystal Report viewer sample using C# code in vs2010