|
-
July 10th, 2000, 09:35 AM
#1
Connection Ojbect
Can anyone help me with the following code? I'm getting, "Invalid use of New keyword", when I try to run it. Thanks so much for your help!
Private Sub cmdSubmit_Click()
Dim cnBusinessRule As Connection
Dim sSQL As String
Set cnBusinessRule = New Connection
'Establish a connection
With cnBusinessRule
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "User ID = sa; password=;" & _
"Data Source=C:\BusinessRules\Database\BusinessRule.mdb;" & _
"Initial Catalog=BusinessRule"
.Open
End With
sSQL = "INSERT INTO GOV_AUTHORITY(Name, Category) " & _
"VALUES (txtName, cmbCategory)"
cnBusinessRule.Execute sSQL
cnBusinessRule.Close
Set cnBusinessRule = Nothing
End Sub
-
July 10th, 2000, 10:46 AM
#2
Re: Connection Ojbect
Try:
private Sub cmdSubmit_Click()
Dim cnBusinessRule as new Adodb.Connection
Dim sSQL as string
set cnBusinessRule = adodb.Connection
'Establish a connection
With cnBusinessRule
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "User ID = sa; password=;" & _
"Data Source=C:\BusinessRules\Database\BusinessRule.mdb;" & _
"Initial Catalog=BusinessRule"
.Open
End With
sSQL = "INSERT INTO GOV_AUTHORITY(Name, Category) " & _
"VALUES (txtName, cmbCategory)"
cnBusinessRule.Execute sSQL
cnBusinessRule.Close
set cnBusinessRule = nothing
End Sub
Regards
Anne Wright
Wright Computing
-
July 10th, 2000, 11:21 AM
#3
Re: Connection Ojbect
Anne,
Thanks for your reply...I've tried with your code and am now getting, "Method or data member not found", message. In order to use the ADO connection, do I need to bind it to the form before I can use it?
Thanks again Anne.
-
July 10th, 2000, 11:32 AM
#4
Re: Connection Ojbect
Try:
private Sub cmdSubmit_Click()
Dim cnBusinessRule as new Adodb.Connection
Dim sSQL as string
'Establish a connection
With cnBusinessRule
.Provider "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "User ID = sa; password=;" & _ "Data Source=C:\BusinessRules\Database\BusinessRule.mdb;" & _ "Initial Catalog=BusinessRule"
.Open End With sSQL = "INSERT INTO GOV_AUTHORITY(Name, Category) " & _ "VALUES (txtName, cmbCategory)" cnBusinessRule.Execute sSQL cnBusinessRule.Close
set cnBusinessRule = nothing
End Sub
-
July 10th, 2000, 12:56 PM
#5
Re: Connection Ojbect
Hi.
I've tried with your code and I now get a runtime error on the .Open statement.
Any ideas?
Thanks again.
Morgan
-
July 10th, 2000, 07:39 PM
#6
Re: Connection Ojbect
There could be many reasons for this..
Since there is no error on your ADODB object model instantiation statments now this tells me that instantiation is fine.
Runtime errors could be due to the mdb file not being in the path specified..
Step thru your code and try to figure out the error
best of luck!!
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
|