[DBNETLIB][ConnectionOpen (Invalid Instance()).]Invalid connection

tolee

New member
Joined
May 15, 2007
Messages
1
Programming Experience
Beginner
Dim strConn As String
Dim oRs As ADODB.Recordset
Dim SQL As String



strConn = "Provider=SQLOLEDB.1;user id=sa;pwd=123;initial catalog=dbname;data source=machine name"
oRs = New ADODB.Recordset()
oRs.CursorLocation = CursorLocationEnum.adUseClient ' ADO bookmarks support


SQL = "SELECT *, ? as x, ? as y From (name) WHERE ?= ? "
oRs.Open(SQL, strConn, CursorTypeEnum.adOpenKeyset, LockTypeEnum.adLockReadOnly, CommandTypeEnum.adCmdText)

error when open database, Please help Me...
 
Last edited:
you cannot parameterise which column names to select in that way

VB.NET:
SELECT
  CASE 
    WHEN @colName = 'ABC' THEN abc
    WHEN @colName = 'DEF' THEN def
  END as col1

FROM
  tblTable

WHERE
  CASE 
    WHEN @colName = 'ABC' THEN abc
    WHEN @colName = 'DEF' THEN def
  END = @colValue


Which tbh is one of the lamest, stupid slow ways of writing a query i ever saw. DONT do it.
 
Back
Top