468,133 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

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 3889
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
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.