Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to create .mdf file

how to create .mdf file

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bhattiprolu
    wrote on last edited by
    #1

    hi all, i want to know how to create .mdf file under my App_data in my application. can any one guide me how to achieve this???????

    A 2 Replies Last reply
    0
    • B bhattiprolu

      hi all, i want to know how to create .mdf file under my App_data in my application. can any one guide me how to achieve this???????

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Hi, here is ur soln:-D:-D:-D u have a to add a Com Reference for IT :cool: Microsoft ADO Ext. 2.8 for DDL and Security Reference > right Click > COM Tab Select that on !!!!!!! :cool: Now , use that code Using ADOX; private void Form1_Load(object sender, EventArgs e) { ADOX.CatalogClass mYcat = new ADOX.CatalogClass(); mYcat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=D:\\NewMDB1.mdb;" + "Jet OLEDB:Engine Type=5"); MessageBox.Show ("Database Created Successfully"); mYcat = null; } yup.... Done !!!!! :) :) :) :) :) :cool:

      Happy Programming ----- Abhijit

      B 1 Reply Last reply
      0
      • B bhattiprolu

        hi all, i want to know how to create .mdf file under my App_data in my application. can any one guide me how to achieve this???????

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        SqlConnection myConn = new SqlConnection("Server=" + servername + " ;Integrated security=SSPI;database=master"); str = "CREATE DATABASE " + Database name + " ON PRIMARY " + "(NAME = MyDatabase_Data, " + mdf_filename + //"FILENAME = 'C:\\MyDatabaseData.mdf', " + "SIZE = 2MB, MAXSIZE = 10MB, FILEGROWTH = 10%) " + "LOG ON (NAME = MyDatabase_Log, " + ldf_filename + //"FILENAME = 'C:\\MyDatabaseLog.ldf', " + "SIZE = 1MB, " + "MAXSIZE = 5MB, " + "FILEGROWTH = 10%)"; SqlCommand myCommand = new SqlCommand(str, myConn); myConn.Open(); myCommand.ExecuteNonQuery(); It will create database as well ur mdf file ....... :)

        Happy Programming ----- Abhijit

        1 Reply Last reply
        0
        • A Abhijit Jana

          Hi, here is ur soln:-D:-D:-D u have a to add a Com Reference for IT :cool: Microsoft ADO Ext. 2.8 for DDL and Security Reference > right Click > COM Tab Select that on !!!!!!! :cool: Now , use that code Using ADOX; private void Form1_Load(object sender, EventArgs e) { ADOX.CatalogClass mYcat = new ADOX.CatalogClass(); mYcat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=D:\\NewMDB1.mdb;" + "Jet OLEDB:Engine Type=5"); MessageBox.Show ("Database Created Successfully"); mYcat = null; } yup.... Done !!!!! :) :) :) :) :) :cool:

          Happy Programming ----- Abhijit

          B Offline
          B Offline
          bhattiprolu
          wrote on last edited by
          #4

          Hi Abhijit, i want to know how to copy my tables, stored procedures from one file to another file. can you guide me wat to do..

          A 1 Reply Last reply
          0
          • B bhattiprolu

            Hi Abhijit, i want to know how to copy my tables, stored procedures from one file to another file. can you guide me wat to do..

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            i belive you want to copy some table from one database to another one !!!! please confirm me !!!! u can use this link also !!! :cool: http://www.codeproject.com/cs/database/GenericCopyTableDataFcn.asp[^]

            Happy Programming ----- Abhijit

            B 1 Reply Last reply
            0
            • A Abhijit Jana

              i belive you want to copy some table from one database to another one !!!! please confirm me !!!! u can use this link also !!! :cool: http://www.codeproject.com/cs/database/GenericCopyTableDataFcn.asp[^]

              Happy Programming ----- Abhijit

              B Offline
              B Offline
              bhattiprolu
              wrote on last edited by
              #6

              yup.. i want to transfer all my tables and stored procedures from one database to another database.

              A 1 Reply Last reply
              0
              • B bhattiprolu

                yup.. i want to transfer all my tables and stored procedures from one database to another database.

                A Offline
                A Offline
                Abhijit Jana
                wrote on last edited by
                #7

                http://www.codeproject.com/useritems/SqlBulkCopy_in_ADONET.asp?df=100&forumid=466499&exp=0&select=2252069[^] please try this one !!!! :)

                Happy Programming ----- Abhijit

                B 1 Reply Last reply
                0
                • A Abhijit Jana

                  http://www.codeproject.com/useritems/SqlBulkCopy_in_ADONET.asp?df=100&forumid=466499&exp=0&select=2252069[^] please try this one !!!! :)

                  Happy Programming ----- Abhijit

                  B Offline
                  B Offline
                  bhattiprolu
                  wrote on last edited by
                  #8

                  cant we move directly means by writing script or some thing like that.. instead of writing code for this?

                  A 1 Reply Last reply
                  0
                  • B bhattiprolu

                    cant we move directly means by writing script or some thing like that.. instead of writing code for this?

                    A Offline
                    A Offline
                    Abhijit Jana
                    wrote on last edited by
                    #9

                    if you want to move directly table and all other things.... u can use either copy option or import option in SQL Server!!!! it will copy all table and procedure to a new table !!!!

                    Happy Programming ----- Abhijit

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups