Create Database Ms SQl server
-
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.
-
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.
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:
-
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:
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
-
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
-
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?
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.
-
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
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:
-
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:
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")
-
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")
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:
-
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.
-
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.