|
-
Jun 29th, 2010, 07:49 PM
#1
[RESOLVED] Can't connect to SQL Server Express 2008 database
When trying to connect to a SQL Server Express 2008 database, I receive the following error:
Failed to generate a user instance of SQL Server. Only an integrated connection can generate a user instance. The connection will be closed.
Which occurs on my "connection" line:
VB.NET Code:
Dim connection As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=dbISTme!.mdf;Integrated Security=False;User ID=test;Password=test1;User Instance=True") Dim command As New SqlCommand("SELECT COUNT(*) FROM Credentials WHERE UserID = @UserID AND Password = @Password", _ connection) With command.Parameters .AddWithValue("@UserID", Me.txtUserName.Text) .AddWithValue("@Password", Me.txtPasssword.Text) End With connection.Open() If CInt(command.ExecuteScalar()) = 0 Then Else Me.DialogResult = Windows.Forms.DialogResult.OK End If connection.Close()]
I've worked with SQL CE databases in the past and I've never had a problem with them. The connection strings are a little bit different, so I think that might have something to do with it.
Originally, I looked up that error and got a whole bunch of nonsense. I found two solutions that worked for most people, but they did not work for me. The fist was an issue with XP and SP2, which I'm Windows 7. The second resolution was to delete the SQLEXPRESS folder.
Then I saw a post from another site:
One thing to remember is that although user instances is the default when working with Visual Studio, it is not mandatory to use them, it is quite possible to attach to databases in the traditional way from SQL Express, to do this you just need to edit the connection string and delete the "user Instance=true". User Instances just make it easier (when it does work) to work with databases as though they were files.
So, I deleted that line and got another error:
An attempt to attach an auto-named database for file dbISTme!.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
This seems like the most generic error ever. There's even less information about this error.
I've made sure that the database uses the SQL authentication and not Windows and made sure my user, "test", has the correct permission.
Anyone have any on ideas on what I'm doing wrong?
Thanks
Last edited by weirddemon; Jun 29th, 2010 at 09:23 PM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|