Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

SQL Connections & Record Select

Hi guys.

I am trying to convert a vbscript over to .net 2005 , i have sorted out the connection part but what i am having problems with is the

db.Execute which gives me an error of Execute is not a member of the 'system.data.odbc.odbcconnection'

And rs.eof which gives me an error of Option Strict on disallows late binding

Has anyone got any ideas? please note i am very new to vb

Private Sub CheckiManageInitialsButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckiManageInitialsButton.Click

Dim strImanage As String
Dim db As New Odbc.OdbcConnection
Dim rs As Object

strImanage = iManageInitialsTextBox.Text

'==============================
'This is the UK iManage Server
'==============================

Dim myConnString As String = _
"Provider=SQLOLEDB.1;Password=PASSWORD HERE;Persist Security Info=True;User ID=USER ID HERE;Initial Catalog=Imdbprecedent;Data Source=IP ADDRESS HERE"
Dim myConnection As New Odbc.OdbcConnection(myConnString)
myConnection.Open()

rs = CreateObject("ADODB.recordset")
rs = db.Execute("select userid from mhgroup.docusers where userid = '" & strImanage & "'")

If Not rs.eof Then
MsgBox("UserName: " & strImanage & " is NOT available in the UK iManage system" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Please do not use this User ID as its in use", 64, "Alert - PLEASE READ , PLEASE READ")
Else
MsgBox("UserName: " & strImanage & " is available in the UK iManage system", 64, "Alert - PLEASE READ , PLEASE READ")
End If

myConnection.Close()
End Sub
[1888 byte] By [cjwallaceUK] at [2007-11-11 10:25:40]
# 1 Re: SQL Connections & Record Select
If you're accessing SQL Server, you should use the SqlConnection and SqlDataReader types, rather than the OdbcConnection, etc. Here are the basics: http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/sqldtreader.aspx
Phil Weber at 2007-11-11 20:47:45 >