Using this connection string from Vb.net 2005 runs successfully:
"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program
Files\SQLTest\Database1.mdf;Integrated Security=True;User Instance=True"
I have gone to a previous application written in VB 6 to replace Jet/ACCESS
database files with SQL Express 2005 files. I have tried 2 suggested
connection strings to the same database file illustrated above without
success.
cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"AttachDBFileName= C:\Program Files\SQLTest\Database1.mdf;Data
Source=.\SQLEXPRESS"
and
cn.ConnectionString =
"Provider=SQLNCLI;Server=.\SQLExpress;AttachDbFilename=C:\Program
Files\SQLTest\Database1.mdf;Trusted_Connection=Yes;"
Both attempts show the following error message:
"CREATE DATABASE permission denied in database 'master'
Thanks in advance.
Sue Severson - 16 Oct 2007 19:52 GMT
I wondered if you have solved this problem. I am also trying to connect
to SQL Server Express from VB6 - replacing an Access backend with
Express.
I got this to work on the local machine:
myDB.ConnectionString = "Provider=SQLNCLI;Server=.\SQLEXPRESS;Database="
& gsDatabase & ";Trusted_Connection=yes;AttachDBFilename=" &
gstrDataPath & conBackEndServer & ";"
But when I try to connect over a network, I can't get it to work. So I
added a user name and try to connect with that on the local machine. I
get an error: "Create database permission denied in database 'master'.
This is my new connection string:
myDB.ConnectionString = "Provider=SQLNCLI;Server=.\SQLEXPRESS;Database="
& gsDatabase & ";AttachDBFilename=" & gstrDataPath & conBackEndServer &
";Initial Catalog=" & conBackEndServerMDB & ";User Id=" & gSqlUser &
";pwd=" & gconPassword & ";"
Would appreciate any help with this.