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

W

Wade

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)
 
W

Wade

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top