Click here to Skip to main content
15,918,125 members
Home / Discussions / Database
   

Database

 
GeneralRe: Transactional Replicated Databases And Changing Schema Pin
wizardzz8-Mar-11 8:34
wizardzz8-Mar-11 8:34 
GeneralRe: Transactional Replicated Databases And Changing Schema Pin
Wendelius8-Mar-11 11:24
mentorWendelius8-Mar-11 11:24 
QuestionUnable to create database programmatically Pin
Helfdane7-Mar-11 10:44
Helfdane7-Mar-11 10:44 
AnswerRe: Unable to create database programmatically Pin
Wendelius7-Mar-11 11:56
mentorWendelius7-Mar-11 11:56 
GeneralRe: Unable to create database programmatically Pin
Helfdane8-Mar-11 1:24
Helfdane8-Mar-11 1:24 
GeneralRe: Unable to create database programmatically Pin
Wendelius8-Mar-11 8:21
mentorWendelius8-Mar-11 8:21 
AnswerRe: Unable to create database programmatically Pin
PIEBALDconsult7-Mar-11 16:34
mvePIEBALDconsult7-Mar-11 16:34 
AnswerRe: Unable to create database programmatically Pin
Roger Wright7-Mar-11 17:23
professionalRoger Wright7-Mar-11 17:23 
A while back I was trying to do the same, and several helpful souls told me it can't be done. Well, that just gets my dander up, so I went ahead and did it:

private void btnCreateDatabase_Click(object sender, EventArgs e)
        {
            String str;
            SqlConnection myConn = new SqlConnection
                ("Server=BAAL\\SQLEXPRESS2;Integrated security=SSPI ;database=master");
            str = "CREATE DATABASE MyDatabase";
            SqlCommand myCommand = new SqlCommand(str, myConn);
            try
            {
                myConn.Open();
                myCommand.ExecuteNonQuery();
                MessageBox.Show("Database Created Successfully", "MyApp", 
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "MyApp", MessageBoxButtons.OK, 
                    MessageBoxIcon.Information);
            }
            finally
            {
                if (myConn.State == ConnectionState.Open)
                {
                    myConn.Close();
                }
            }

        }


I ran it once, then switched over to the server to check - sure enough, myDatabease was there, ready to be populated.

Your app will certainly need more, but it works, and should get you started. Smile | :)
Will Rogers never met me.

GeneralRe: Unable to create database programmatically Pin
Helfdane8-Mar-11 1:24
Helfdane8-Mar-11 1:24 
QuestionAudit Trail : Single table for all users or multiple table per user Pin
eight6-Mar-11 22:35
eight6-Mar-11 22:35 
AnswerRe: Audit Trail : Single table for all users or multiple table per user Pin
WoutL6-Mar-11 22:53
WoutL6-Mar-11 22:53 
AnswerRe: Audit Trail : Single table for all users or multiple table per user Pin
musefan6-Mar-11 22:57
musefan6-Mar-11 22:57 
GeneralRe: Audit Trail : Single table for all users or multiple table per user Pin
Dave Kerr6-Mar-11 23:03
mentorDave Kerr6-Mar-11 23:03 
GeneralRe: Audit Trail : Single table for all users or multiple table per user Pin
musefan6-Mar-11 23:36
musefan6-Mar-11 23:36 
AnswerRe: Audit Trail : Single table for all users or multiple table per user Pin
Eddy Vluggen7-Mar-11 0:15
professionalEddy Vluggen7-Mar-11 0:15 
AnswerRe: Audit Trail : Single table for all users or multiple table per user Pin
Wendelius7-Mar-11 1:52
mentorWendelius7-Mar-11 1:52 
QuestionUpgrading MSDE SP4 to SQL 2008 Express R2 Pin
Elsie6-Mar-11 19:46
Elsie6-Mar-11 19:46 
QuestionSQL Help - sum items based on max but also smaller than...? Pin
GlobX6-Mar-11 17:09
GlobX6-Mar-11 17:09 
AnswerRe: SQL Help - sum items based on max but also smaller than...? Pin
Wendelius7-Mar-11 7:40
mentorWendelius7-Mar-11 7:40 
GeneralRe: SQL Help - sum items based on max but also smaller than...? [modified] Pin
GlobX7-Mar-11 12:12
GlobX7-Mar-11 12:12 
GeneralRe: SQL Help - sum items based on max but also smaller than...? Pin
Wendelius7-Mar-11 18:37
mentorWendelius7-Mar-11 18:37 
AnswerRe: SQL Help - sum items based on max but also smaller than...? Pin
GlobX7-Mar-11 13:05
GlobX7-Mar-11 13:05 
Questioncopy data from 1 table to another table Pin
bapu28895-Mar-11 6:07
bapu28895-Mar-11 6:07 
AnswerRe: copy data from 1 table to another table Pin
Mycroft Holmes5-Mar-11 12:07
professionalMycroft Holmes5-Mar-11 12:07 
AnswerRe: copy data from 1 table to another table Pin
PIEBALDconsult5-Mar-11 14:48
mvePIEBALDconsult5-Mar-11 14:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.