-
Oct 22nd, 2020, 11:09 AM
#1
Thread Starter
New Member
Issues with connecting to SQL Server from VB.Net using SQLOLEDB connection string
Hi! Hope you are well.
I want to use ADO recordsets against a SQL Server database.
I am trying to connect to a Sql Server database using the connnection string
"Provider=SQLOLEDB;Data Source=HSSQL001;Initial Catalog=2020_Consumer_13;Trusted_Connection=yes;"
My code is:
Code:
Private Sub LoadDataForEdit()
Dim a26fields(25) As String
Dim conn As New ADODB.Connection
Dim strRequestedId As String = "" ' = txtSurveyId.Text
If txtSurveyId.Text <> "" Then
strRequestedId = txtSurveyId.Text
conn.ConnectionString = "Provider=SQLOLEDB;Data Source=HSSQL001;Initial Catalog=2020_Consumer_13;Trusted_Connection=yes;"
conn.Open()
Call ChildClearForm()
Dim ssql As String
Dim objRecordset As New ADODB.Recordset
ssql = "Select * FROM [2020Survey] WHERE Id = '" & strRequestedId & "'"
objRecordset.Open(ssql, sconn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
If objRecordset.RecordCount = 0 Then
MessageBox.Show("Survey Id: " & strRequestedId & " does not exist in the database!", "CONSUMER SURVEY", MessageBoxButtons.OK)
Else
With objRecordset
Process Recordset
End With
End
End If
End Sub
I get an error: [DBNETLIB][ConnectionOpen (SECDoClientHandshake()).]SSL Security error.
If someone could please assist me.
-
Oct 23rd, 2020, 05:57 AM
#2
Re: Issues with connecting to SQL Server from VB.Net using SQLOLEDB connection string
I Googled the error and there are several things worth trying in this article along with a brief description of what goes on under the covers.
https://www.sqlnethub.com/blog/dbnet...error-resolve/
Please remember next time...elections matter!
-
Oct 23rd, 2020, 09:06 AM
#3
Re: Issues with connecting to SQL Server from VB.Net using SQLOLEDB connection string
Is there a reason for using SQLOLEDB and ADO and not ADO.Net with a proper provider?
-tg
-
Oct 23rd, 2020, 08:55 PM
#4
Re: Issues with connecting to SQL Server from VB.Net using SQLOLEDB connection string
I see that you have been using VB.NET for several years so I also have to question why you aren't using it "properly". If you're upgrading a VB6 application that already uses ADO then that's one thing. If you're writing new VB.NET code from scratch though, there's no excuse for not using ADO.NET. You may have a reason, e.g. you know ADO better than ADO.NET, but it's most likely not a good reason. If this is work and you're supervisor is telling you to use ADO then I guess you have no choice but it's still a very bad choice.
-
Oct 26th, 2020, 12:52 PM
#5
Re: Issues with connecting to SQL Server from VB.Net using SQLOLEDB connection string
All of this would be a lot easier and cleaner if you just used ADO.Net instead of ADO as jmc suggested.
Also, I noticed that the Integrated Security variable is missing from your connection string. I am of course assuming that the instance of SQL Server that you're trying to connect to is using Windows authentication.
Last edited by Niya; Oct 26th, 2020 at 12:55 PM.
-
Oct 26th, 2020, 06:34 PM
#6
Re: Issues with connecting to SQL Server from VB.Net using SQLOLEDB connection string
Originally Posted by Niya
Also, I noticed that the Integrated Security variable is missing from your connection string.
Trusted_Connection is a synonym for Integrated Security. In theory, they should do the same thing.
Tags for this Thread
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
|