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. Database & SysAdmin
  3. Database
  4. Create Database Ms SQl server

Create Database Ms SQl server

Scheduled Pinned Locked Moved Database
databasesql-serversysadminquestion
10 Posts 3 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.
  • M Offline
    M Offline
    Mangore75
    wrote on last edited by
    #1

    I'm using VB2008 I created a MsAccess 2003 database connection to my project,and make my project exe application. and put it with database Access in one folder and it worked well. Now I 'm working on the Ms sql server database. I created a DataBase called MyDBs and made connection with it with Vb2008. My question is can I create Ms Sql database(MyDBs) movable,attachement . means as I did with database access, by put it with application exe in same folder. I hope I'm clear.

    L 1 Reply Last reply
    0
    • M Mangore75

      I'm using VB2008 I created a MsAccess 2003 database connection to my project,and make my project exe application. and put it with database Access in one folder and it worked well. Now I 'm working on the Ms sql server database. I created a DataBase called MyDBs and made connection with it with Vb2008. My question is can I create Ms Sql database(MyDBs) movable,attachement . means as I did with database access, by put it with application exe in same folder. I hope I'm clear.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Yes, by changing the connectionstring[^]. Look under the header "Attach a database file on connect to a local SQL Server Express instance". Your customers will still need to have Sql Server installed, regardless. If your database is local to the app (say, in the same folder) then stick with Access, or go for SqlCe. If your database needs to support more than a single user, you use Sql Server - in a centralized place where everybody who needs to access the database, can access it.

      Bastard Programmer from Hell :suss:

      M 1 Reply Last reply
      0
      • L Lost User

        Yes, by changing the connectionstring[^]. Look under the header "Attach a database file on connect to a local SQL Server Express instance". Your customers will still need to have Sql Server installed, regardless. If your database is local to the app (say, in the same folder) then stick with Access, or go for SqlCe. If your database needs to support more than a single user, you use Sql Server - in a centralized place where everybody who needs to access the database, can access it.

        Bastard Programmer from Hell :suss:

        M Offline
        M Offline
        Mangore75
        wrote on last edited by
        #3

        I made this for dtatbase: Script database as - CREATE TO - File and took the file Of DataBase(MyDBs) and put it in Debug folder in my project. then I tried this way but didn't succed with me.

        Dim MyConnection As SqlConnection = New SqlConnection("Data Source=.\SQLExpress; Integrated Security=true; AttachDbFilename=|DataDirectory|\MyDBs.sql;")
        Public Sub Load_DB()
        Dim sql As String = " Select Name,Tel,Addr from Table1 "
        Dim dp As New SqlDataAdapter(sql, MyConnection)

            Dim Table1 As New DataTable
            dp.Fill(Table1)
            Form1.DataGridView1.DataSource = Table1
        End Sub
        
        J L 2 Replies Last reply
        0
        • M Mangore75

          I made this for dtatbase: Script database as - CREATE TO - File and took the file Of DataBase(MyDBs) and put it in Debug folder in my project. then I tried this way but didn't succed with me.

          Dim MyConnection As SqlConnection = New SqlConnection("Data Source=.\SQLExpress; Integrated Security=true; AttachDbFilename=|DataDirectory|\MyDBs.sql;")
          Public Sub Load_DB()
          Dim sql As String = " Select Name,Tel,Addr from Table1 "
          Dim dp As New SqlDataAdapter(sql, MyConnection)

              Dim Table1 As New DataTable
              dp.Fill(Table1)
              Form1.DataGridView1.DataSource = Table1
          End Sub
          
          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Mangore75 wrote:

          then I tried this way but didn't succed with me.

          HOW didn't is succeed? What EXACTLY happened so you know it didn't work?

          M 1 Reply Last reply
          0
          • J jschell

            Mangore75 wrote:

            then I tried this way but didn't succed with me.

            HOW didn't is succeed? What EXACTLY happened so you know it didn't work?

            M Offline
            M Offline
            Mangore75
            wrote on last edited by
            #5

            it showed me this error; An attempt to attach an auto-named database for file C:\Users\Nader\Desktop\OOP- CreatProject\OOP- CreatProject\bin\Debug\MyDBs.sql failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

            J L 2 Replies Last reply
            0
            • M Mangore75

              I made this for dtatbase: Script database as - CREATE TO - File and took the file Of DataBase(MyDBs) and put it in Debug folder in my project. then I tried this way but didn't succed with me.

              Dim MyConnection As SqlConnection = New SqlConnection("Data Source=.\SQLExpress; Integrated Security=true; AttachDbFilename=|DataDirectory|\MyDBs.sql;")
              Public Sub Load_DB()
              Dim sql As String = " Select Name,Tel,Addr from Table1 "
              Dim dp As New SqlDataAdapter(sql, MyConnection)

                  Dim Table1 As New DataTable
                  dp.Fill(Table1)
                  Form1.DataGridView1.DataSource = Table1
              End Sub
              
              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Why did you expect it too succeed? :) Sql isn't the same beast as Access. You'll need to have a server installed, connect to that, and *hope* that you have sufficient rights to create a database on that server. Is there a server installed? Can you connect to the master-database on "127.0.0.1\SqlExpress"?

              Bastard Programmer from Hell :suss:

              M 1 Reply Last reply
              0
              • L Lost User

                Why did you expect it too succeed? :) Sql isn't the same beast as Access. You'll need to have a server installed, connect to that, and *hope* that you have sufficient rights to create a database on that server. Is there a server installed? Can you connect to the master-database on "127.0.0.1\SqlExpress"?

                Bastard Programmer from Hell :suss:

                M Offline
                M Offline
                Mangore75
                wrote on last edited by
                #7

                I ahve a server installed and it succedd with this conetion but the daabase doesn't in the folder debug. but I tried to use the same way as I did with access, by put the file i debug as I said in my first post.

                Dim MyConnection As SqlConnection = New SqlConnection("Data Source=Name-PC\SQLEXPRESS;Integrated Security=true;Initial Catalog=MyDBs")

                L 1 Reply Last reply
                0
                • M Mangore75

                  I ahve a server installed and it succedd with this conetion but the daabase doesn't in the folder debug. but I tried to use the same way as I did with access, by put the file i debug as I said in my first post.

                  Dim MyConnection As SqlConnection = New SqlConnection("Data Source=Name-PC\SQLEXPRESS;Integrated Security=true;Initial Catalog=MyDBs")

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  It's not Access - Sql databases aren't meant to be portable. The user that the server is running under needs read/write access on that path. Your connection-string also doesn't mention which db-file to attach. I suggest you use the connection-string that I pointed to.

                  Bastard Programmer from Hell :suss:

                  1 Reply Last reply
                  0
                  • M Mangore75

                    it showed me this error; An attempt to attach an auto-named database for file C:\Users\Nader\Desktop\OOP- CreatProject\OOP- CreatProject\bin\Debug\MyDBs.sql failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

                    J Offline
                    J Offline
                    jschell
                    wrote on last edited by
                    #9

                    Error seems to be specifically telling what the possible problems are.

                    1 Reply Last reply
                    0
                    • M Mangore75

                      it showed me this error; An attempt to attach an auto-named database for file C:\Users\Nader\Desktop\OOP- CreatProject\OOP- CreatProject\bin\Debug\MyDBs.sql failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      Only one instance with the name of the database is allowed on the server. Detach the database that's connected, or use an other name.

                      Bastard Programmer from Hell :suss:

                      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