Click to See Complete Forum and Search --> : asp form


jmaresca2005
06-03-2005, 10:26 AM
i have a form that writes to text a file however i want to convert this functionality to store data in SQL server. please advise. I have done this before but havent worked with asp forms in awhile i need a memory refresher.

lmf232s
06-03-2005, 10:50 AM
well you will need to set up a table
Then you will need to make a database connection
Open the query
Save the results
Close the DB


DB COnnection
strConnection = "Provider=sqloledb;Data Source=ServerName;Initial Catalog=DataBaseName;USER ID=?;PASSWORD=?;"
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnection
Set objRS = Server.CreateObject("ADODB.Recordset")


objRS.Open "TableName", objConn, 3, 3 ' i can use 3 and 3 becuase i have the adovbs include file, do a search on this and you can find it else you will have to use this

objRS.Open "tableName", objConn, adOpenStatic, adLockOptimistic (or what ever you want)
objRS.AddNew
objRS("FIeldName") = "SOmething"
objRS.Update
objRS.Close

set objRS = Nothing
set objConn = Nothing


or you can use the insert statement instead

SQL = "INSERT INTO table_name (column1, column2,...) " & _
"VALUES (value1, value2,.....)

set rs = objConn.execute(SQL)

wmif
06-03-2005, 11:19 AM
post up code.