C'mon... nån idé måste ni väl ha åtminstonde...
*bump*
Frågan#1
Jag får inkompatiba typer när jag försöker lägga databaskopplingen i en funktion.
Inkompatibla typer: 'ADODB_Connection' line 14
Detta fungerar utmärkt:
Dim SQL: SQL = "SELECT v.titles, s.score FROM votable v, votes s WHERE s.title = v.id"
Dim DbData ': DbData = ADODB_Connection(ipnummer, databas, "SELECT v.titles, s.score FROM votable v, votes s WHERE s.title = v.id")
Dim oCon: Set oCon = Server.CreateObject("ADODB.Connection")
oCon.Open("Driver={MySql ODBC 3.51 Driver};Server=ipnummer;Database=databas;UID=usr;PWD=pwd;Option=16387;")
Dim ArrData(1): Set ArrData(0) = oCon
If Left(LCase(SQL), 6) = "select" Then
Dim oRs: Set oRs = oCon.Execute(SQL)
If Not oRs.EOF Then ArrData(1) = oRs.GetRows()
Else
oCon.Execute(SQL),,128
End If
DbData = ArrData
If IsArray(DbData(1)) Then
Dim i: For i = 0 To UBound(DbData(1), 2)
Response.Write DbData(1)(0, i) & " " & DbData(1)(1, i) & "<br>"
Next
End If
Detta fungerar inte:
[b]Dim DbData: DbData = ADODB_Connection(ipnummer, databas, "SELECT v.titles, s.score FROM votable v, votes s WHERE s.title = v.id")[/b]
If IsArray(DbData(1)) Then
Dim i: For i = 0 To UBound(DbData(1), 2)
Response.Write DbData(1)(0, i) & " " & DbData(1)(1, i) & "<br>"
Next
End If
Function ADODB_Connection(StrServer, StrDatabase, SQLQuery)
If "" & StrDatabase = "" Or "" & StrServer = "" Or "" & SQLQuery = "" Then Exit Function
Dim oCon: Set oCon = Server.CreateObject("ADODB.Connection")
oCon.Open("Driver={MySql ODBC 3.51 Driver};Server="&StrServer&";Database="&StrDatabase&";UID=uid;PWD=pwd;Option=16387;")
Dim ArrData(1): Set ArrData(0) = oCon
If Left(LCase(SQLQuery), 6) = "select" Then
Dim oRs: Set oRs = oCon.Execute(SQLQuery)
If Not oRs.EOF Then ArrData(1) = oRs.GetRows()
Else
oCon.Execute(SQLQuery),,128
End If
ADODB_Connection = ArrData
End Function
Vad är det jag missar?

