Click here to Skip to main content
16,008,469 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating Access Database in C# VS2005 [modified] Pin
brickbat26-May-07 19:57
brickbat26-May-07 19:57 
GeneralRe: Creating Access Database in C# VS2005 Pin
brickbat27-May-07 2:45
brickbat27-May-07 2:45 
GeneralRe: Creating Access Database in C# VS2005 Pin
Not Active27-May-07 4:55
mentorNot Active27-May-07 4:55 
GeneralRe: Creating Access Database in C# VS2005 Pin
brickbat27-May-07 5:14
brickbat27-May-07 5:14 
GeneralRe: Creating Access Database in C# VS2005 Pin
Paul Conrad27-May-07 7:01
professionalPaul Conrad27-May-07 7:01 
GeneralRe: Creating Access Database in C# VS2005 Pin
Not Active27-May-07 5:00
mentorNot Active27-May-07 5:00 
GeneralRe: Creating Access Database in C# VS2005 Pin
brickbat27-May-07 19:51
brickbat27-May-07 19:51 
AnswerRe: Creating Access Database in C# VS2005 Pin
brickbat27-May-07 22:16
brickbat27-May-07 22:16 
To the trolls, MVP or not - Thanks for no help. Here is correctly working code for those that might be interested. Obviously, the Server location, the database and logfile paths, and the size parameters may need to be changed to suit the application. I will not be using this because as I thought, you need to have an sql server running for this to work. I will not require my users to have an sql server constantly running because of a small finance application which they may use once per month.

Here is correctly working code

<br />
            String str;<br />
            SqlConnection myConn = new SqlConnection("Server=local\\SQLEXPRESS;Integrated security=SSPI;database=master");<br />
<br />
            str = "CREATE DATABASE MyDatabase ON PRIMARY " +<br />
                "(NAME = MyDatabase_Data, " +<br />
                "FILENAME = 'E:\\MyDatabaseData2.mdf', " +<br />
                "SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " +<br />
                "LOG ON (NAME = MyDatabase_Log, " +<br />
                "FILENAME = 'E:\\MyDatabaseLog2.ldf', " +<br />
                "SIZE = 1MB, " +<br />
                "MAXSIZE = 5MB, " +<br />
                "FILEGROWTH = 10%)";<br />
<br />
            SqlCommand myCommand = new SqlCommand(str, myConn);<br />
            try<br />
            {<br />
                myConn.Open();<br />
                myCommand.ExecuteNonQuery();<br />
            }<br />
            catch (System.Exception ex)<br />
            {<br />
                MessageBox.Show(ex.ToString(), "MyProgram", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />
            }<br />
            finally<br />
            {<br />
                if (myConn.State == ConnectionState.Open)<br />
                {<br />
                    myConn.Close();<br />
                }<br />
            }<br />

GeneralRe: Creating Access Database in C# VS2005 Pin
brickbat27-May-07 22:20
brickbat27-May-07 22:20 
QuestionQuestion regarding Image displayed in a Button. Pin
Khoramdin25-May-07 8:48
Khoramdin25-May-07 8:48 
AnswerRe: Question regarding Image displayed in a Button. Pin
Martin#25-May-07 9:02
Martin#25-May-07 9:02 
AnswerRe: Question regarding Image displayed in a Button. Pin
Ian Shlasko25-May-07 10:39
Ian Shlasko25-May-07 10:39 
Questionsend SMS with UMTS modem in application Pin
spotl25-May-07 8:27
spotl25-May-07 8:27 
QuestionId and its Details Pin
Mikeyyy25-May-07 8:16
Mikeyyy25-May-07 8:16 
AnswerRe: Id and its Details Pin
Mikeyyy25-May-07 8:18
Mikeyyy25-May-07 8:18 
GeneralRe: Id and its Details Pin
Tarakeshwar Reddy25-May-07 8:26
professionalTarakeshwar Reddy25-May-07 8:26 
GeneralRe: Id and its Details Pin
Martin#25-May-07 8:43
Martin#25-May-07 8:43 
GeneralRe: Id and its Details Pin
Colin Angus Mackay25-May-07 9:10
Colin Angus Mackay25-May-07 9:10 
AnswerRe: Id and its Details Pin
Tarakeshwar Reddy25-May-07 8:21
professionalTarakeshwar Reddy25-May-07 8:21 
GeneralThanks all !...I liked all of these approaches. Pin
Mikeyyy26-May-07 5:26
Mikeyyy26-May-07 5:26 
QuestionHow to lock the MDI parent form when using Child form Pin
pg_kg25-May-07 7:28
pg_kg25-May-07 7:28 
AnswerRe: How to lock the MDI parent form when using Child form Pin
Tarakeshwar Reddy25-May-07 8:03
professionalTarakeshwar Reddy25-May-07 8:03 
QuestionUndo/Redo Class? Pin
Richard Blythe25-May-07 6:51
Richard Blythe25-May-07 6:51 
AnswerRe: Undo/Redo Class? Pin
Giorgi Dalakishvili25-May-07 7:12
mentorGiorgi Dalakishvili25-May-07 7:12 
AnswerRe: Undo/Redo Class? Pin
Dave Herren25-May-07 17:40
Dave Herren25-May-07 17:40 

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.