471,591 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,591 software developers and data experts.

Is it Possible to connect to SQL 2005 Ex from VB 2005 Ex code?

Is it possible to connect to a SQL 2005 Express db using Visual Basic 2005
Express?

I cannot get past the connection.open statement without the error
"...Version=2.0.0.0; SqlClient.SqlClientPermissions;
PublicKeyToken=b77a5c561934e089 failed."

I have WinXP, SQL Express 2005, and VB 2005 Express all on same machine.
I've found hundreds of samples and tried most of them, but still get same
error.

I would like to publish the code and install on another computer that will
access this computer for the database, but I can't even get it to work on
this one.

Any help would be greatly appreciated, Thanks in advance.

Here are some of the connection strings I've tried:

'*********sql client*********************
Protected Const SqlConnectionString As String= _
"Data Source=localhost;" & _
"AttachDbFilename='R:\dbFileName.mdf'; & _
"Integrated Security=True;" & _
"Connnect Timeout=30;" & _
"User Instance=True;"
Protected connection As String = SqlConnectionString

Dim connection As New SqlConnection(connectionString)
connection.Open()
'**************************************
(I've also tried replacing the line "Data Source" with
"Server=MyCompterName;
and "Server=tcp:MyComputerName;" and "Server=MyComputerName,port"
and "Server=MyComputerName\SQLEXPRESS"
And I've tried removing the line "AttachDbFileName or replacing it with
"Database=dbFileName"
and removing the line "Connect Tiimeout" and "User Instance"
)

'***********ole client************************
Protected Const SqlConnectionString As String= _
"Provider=SqlOledb.1;" & _
"Data Source=MyComputerName; & _
"Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"DataBase=dbFileName;"
Protected connection As String = SqlConnectionString

Dim connection As New OleDbConnection(connectionString)
connection.Open()
'********************************************
(I've tried removing the "Persist Security Info" also)

Dec 1 '05 #1
1 3973
Solved --- maybe...

2 things I did:

1. set the Access Security Policy of LocalInternet Zone to Full Trust -
using Configure Code Access Security Policy Wizard in .Net Framework 2.0
Configuration

2. published the VB 2005 Express and installed on my computer and 2nd test
computer and the installed program worked - Previously I was just running
Debug on my computer.

I don't know which method worked or if I needed to do both.

"Wade" <wn********@preinnewhofdonotreply.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl...
Is it possible to connect to a SQL 2005 Express db using Visual Basic 2005
Express?

I cannot get past the connection.open statement without the error
"...Version=2.0.0.0; SqlClient.SqlClientPermissions;
PublicKeyToken=b77a5c561934e089 failed."

I have WinXP, SQL Express 2005, and VB 2005 Express all on same machine.
I've found hundreds of samples and tried most of them, but still get same
error.

I would like to publish the code and install on another computer that will
access this computer for the database, but I can't even get it to work on
this one.

Any help would be greatly appreciated, Thanks in advance.

Here are some of the connection strings I've tried:

'*********sql client*********************
Protected Const SqlConnectionString As String= _
"Data Source=localhost;" & _
"AttachDbFilename='R:\dbFileName.mdf'; & _
"Integrated Security=True;" & _
"Connnect Timeout=30;" & _
"User Instance=True;"
Protected connection As String = SqlConnectionString

Dim connection As New SqlConnection(connectionString)
connection.Open()
'**************************************
(I've also tried replacing the line "Data Source" with
"Server=MyCompterName;
and "Server=tcp:MyComputerName;" and "Server=MyComputerName,port"
and "Server=MyComputerName\SQLEXPRESS"
And I've tried removing the line "AttachDbFileName or replacing it with
"Database=dbFileName"
and removing the line "Connect Tiimeout" and "User Instance"
)

'***********ole client************************
Protected Const SqlConnectionString As String= _
"Provider=SqlOledb.1;" & _
"Data Source=MyComputerName; & _
"Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"DataBase=dbFileName;"
Protected connection As String = SqlConnectionString

Dim connection As New OleDbConnection(connectionString)
connection.Open()
'********************************************
(I've tried removing the "Persist Security Info" also)

Dec 1 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by JenU | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.