curiouswebster
asked on
Creating my first DB connection in VBA, Excel 2007
If this code throws no error, does that mean it's opening a connection? If so, to what?
It stops nicely at a breakpoint and exits the function gracefully.
Private Sub Worksheet_SelectionChange( ByVal Target As Range)
MsgBox "combo change to WS2"
Dim Myconnection As Connection
Dim Myrecordset As Recordset
Dim MyWorkbook As String
Set Myconnection = New Connection
Set Myrecordset = New Recordset
'Identify the workbook you are referencing
MyWorkbook = Application.ThisWorkbook.F ullName
'Open connection to the workbook
Myconnection.Open "Provider=Microsoft.Jet.OL EDB.4.0;" & _
"Data Source=" & MyWorkbook & ";" & _
"Extended Properties=Excel 8.0;" & _
"Persist Security Info=False"
End Sub
It stops nicely at a breakpoint and exits the function gracefully.
Private Sub Worksheet_SelectionChange(
MsgBox "combo change to WS2"
Dim Myconnection As Connection
Dim Myrecordset As Recordset
Dim MyWorkbook As String
Set Myconnection = New Connection
Set Myrecordset = New Recordset
'Identify the workbook you are referencing
MyWorkbook = Application.ThisWorkbook.F
'Open connection to the workbook
Myconnection.Open "Provider=Microsoft.Jet.OL
"Data Source=" & MyWorkbook & ";" & _
"Extended Properties=Excel 8.0;" & _
"Persist Security Info=False"
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is this table specific code?
Parameters.Append .CreateParameter("QueryTex tParam", adVarChar, adParamInput, 10, StringValue)
.Parameters.Append .CreateParameter("QueryTex tParam", adDouble, adParamInput, , DoubleValue)
.Parameters.Append .CreateParameter("QueryLon gParam", adBigInt, adParamInput, , LongValue)
.Parameters.Append .CreateParameter("QueryDat eParam", adDate, adParamInput, , DateValue)
.Parameters.Append .CreateParameter("QueryDat eTimeStamp Param", adDBTimeStamp, adParamInput, , DateTimeValue)
Parameters.Append .CreateParameter("QueryTex
.Parameters.Append .CreateParameter("QueryTex
.Parameters.Append .CreateParameter("QueryLon
.Parameters.Append .CreateParameter("QueryDat
.Parameters.Append .CreateParameter("QueryDat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
ASKER
BUT, is there a way I can run a very simple query and NOT require a sproc? I am not too quick with T-SQL.