Function ConnectDB() Set objConn = New ADODB.Connection On Error GoTo ConnErr objConn.Mode = adModeRead objConn.ConnectionString = "DSN=xy" objConn.Open Exit Function ConnErr: MsgBox ("Error in connection!") End Function Function QueryDB(strSQL As String) On Error GoTo QueryErr Set objRs = New ADODB.Recordset objRs.Open strSQL, objConn objRs.MoveFirst MsgBox (objRs.RecordCount) 'MsgBox (objRs.Fields(1).Value) Exit Function QueryErr: MsgBox ("Error in query!") End Function Function DoIt() ConnectDB QueryDB ("Select * from Item") End Function
Comments
This is the correct code:
Now I have still one problem:
How to set the company via Code?
This works as long as the company is set in the dsn (
Any ideas?
Thanks
Thomas