dcsimg

Code Example 1:

Set conn =  Server.CreateObject("ADODB.Connection")
conn.Open "FILEDSN= C:\Program Files\Common Files\ODBC\Data Sources\testDsn.dsn","username", "password"
conn.Execute "INSERT INTO DEMOTABLE VALUES ('FIRST VALUE', 'SECOND VALUE')"
conn.Close

Code Example 2:

conn.Open "FILEDSN= C:\myAspDir\testDsn.dsn"

Code Example 3:

Set RS=conn.Execute "SELECT * FROM DEMOTABLE WHERE ID>10 "

Code Example 4:

Set conn=Server.CreateObject("ADODB.Connection")
Set RS   =Server.CreateObject("ADODB.RecordSet")
conn.Open "FILEDSN= C:\Program Files\Common Files\ODBC\Data Sources\testDsn.dsn","username", "password"
RS.Open "SELECT * FROM MYTABLE WHERE MYRECORDNO>0", conn, adOpenDynamic, adLockPessimestic, adCMDText
WHILE NOT RS.EOF
   Response.write "<br>"&RS("CloumnName")
   RS.MoveNext
WEND
RS.Close
conn.Close

Code Example 5:

1. Set conn = Server.CreateObject("ADODB.Connection")
2. Set myCommand= Server.CreateObject("ADODB.Command")
3. myCommand.setActiveConnection = "FILEDSN= C:\myAspDir\testDsn.dsn", "username", password"
4. myCommand.CommandText = "(Call recordCount(?))"
5. myCommand.Parameters.Append myCommand.CreateParameter ("cnt", adInteger, adParamObject)
6. myCommand.Execute
7. Response.write "Record Count = "&myCommand(0)

Code Example 6:

On Error Resume Next
Set conn =  Server.CreateObject("ADODB.Connection")
conn.Open "FILEDSN= C:\Program Files\Common Files\ODBC\Data Sources\testDsn.dsn","username", "password"
conn.Execute "INSERT INTO DEMOTABLE VALUES ('FIRST VALUE', 'SECOND VALUE')"
conn.Close
If Err.Number > 0 then
Response.write  "Cannot insert into DemoTable<br>"
Response.write  "Error Number = " & Err.Number
Response.write  "Source=  " 	& Err.Source
Response.write   "Description = " & Err.Description
End If