Jim_Moten
04-09-2003, 03:03 PM
I recently inherited a database developed by someone with complete disregard for SQL syntax....Trying to connect to Db and obtain schema. Using the following code with no recordset being returned...Connection appears to be working, forced to use DSN-less because, well you'll see why.
Dim oConn
Set oConn = Server.CreateObject("ADODB.Connection")
'oConn.Properties("Prompt") = adPromptAlways
oConn.ConnectionString = "Driver={SQL Server};"
oConn.ConnectionString = oConn.ConnectionString & "Server=sqlserver;Database=Plant;"
oConn.ConnectionString = oConn.ConnectionString & "Trusted_Connection=no;uid=cr_reader;pwd=cr"
oConn.Open
Dim oRS,sqlText
Set oRS = Server.CreateObject("ADODB.Connection")
sqlText = "SELECT * FROM plant_schedule;"
oRS.Open sqlText, "DSN=Plant"
'oRS.Open "SELECT CUSTOMER FROM dbo_**plant_schedule**;" too long?
Response.Write "<table border='1'>"
Do while NOT oRS.EOF
Response.Write "<tr><td>" & oRS("customer") & " </td></tr>"
oRS.MoveNext
Loop
Response.Write "</table>"
oRS.Close
Set oRS = Nothing
Response.Expires = 0
Errors rec'd where indicated and why...Here is syntax that executes in SQL Analyzer:
SELECT
A__plant_schedule___."jobnum", A__plant_schedule___."customer", A__plant_schedule___."prs"
FROM
"Plant"."dbo"."** plant_schedule **" A__plant_schedule___
Somebody please help me return a recordset.
Dim oConn
Set oConn = Server.CreateObject("ADODB.Connection")
'oConn.Properties("Prompt") = adPromptAlways
oConn.ConnectionString = "Driver={SQL Server};"
oConn.ConnectionString = oConn.ConnectionString & "Server=sqlserver;Database=Plant;"
oConn.ConnectionString = oConn.ConnectionString & "Trusted_Connection=no;uid=cr_reader;pwd=cr"
oConn.Open
Dim oRS,sqlText
Set oRS = Server.CreateObject("ADODB.Connection")
sqlText = "SELECT * FROM plant_schedule;"
oRS.Open sqlText, "DSN=Plant"
'oRS.Open "SELECT CUSTOMER FROM dbo_**plant_schedule**;" too long?
Response.Write "<table border='1'>"
Do while NOT oRS.EOF
Response.Write "<tr><td>" & oRS("customer") & " </td></tr>"
oRS.MoveNext
Loop
Response.Write "</table>"
oRS.Close
Set oRS = Nothing
Response.Expires = 0
Errors rec'd where indicated and why...Here is syntax that executes in SQL Analyzer:
SELECT
A__plant_schedule___."jobnum", A__plant_schedule___."customer", A__plant_schedule___."prs"
FROM
"Plant"."dbo"."** plant_schedule **" A__plant_schedule___
Somebody please help me return a recordset.