
May 3rd, 2000, 09:25 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 24
|
|
|
can't connect with database
<i><b>Originally posted by : anon. (marge_fs@yahoo.com)</b></i><br />Hi, I am trying to connect a webfrom with a database in SQL Server but it doesn't work.<br />The problem is that the values of the form are not entered in the database.<br />Here is the code:<br /><br />Set objConn = Server.CreateObject("ADODB.Connection")<br /> <br />strConn = "Provider=SQLOLEDB.1;" & _<br /> "User ID=wwwuser;" & _<br /> "Initial Catalog=csxfs_proj;" & _<br /> "Persist Security Info=False;" & _<br /> "Data Source=CSIS1"<br /> <br />objConn.Open strConn<br /><br />Set objRS = Server.CreateObject("ADODB.Recordset")<br /><br />If Request.ServerVariables("CONTENT_LENGTH") <> 0 Then<br /> ' Retrieving Form Data from Post command body<br /> strFirstname = Trim(Request.Form("name"))<br /> strLastname = Trim(Request.Form("surname"))<br /> strStudent_id = Trim(Request.Form("student_id"))<br /> strFirstCode = Trim(Request.Form("FirstCode"))<br /> strSecondCode = Trim(Request.Form("SecondCode"))<br /> strThirdCode = Trim(Request.Form("ThirdCode"))<br /> strFirstTitle = Trim(Request.Form("FirstTitle"))<br /> strSecondTitle = Trim(Request.Form("SecondTitle"))<br /> strThirdTitle = Trim(Request.Form("ThirdTitle"))<br /> strFirstDescription = Trim(Request.Form("FirstDescription"))<br /> strFirstDescription = Replace(strFirstDescription, vbcrlf, "<BR>" & vbcrlf)<br /> strSecondDescription = Trim(Request.Form("SecondDescription"))<br /> strSecondDescription = Replace(strSecondDescription, vbcrlf, "<BR>" & vbcrlf)<br /> strThirdDescription = Trim(Request.Form("ThirdDescription"))<br /> strThirdDescription = Replace(strThirdDescription, vbcrlf, "<BR>" & vbcrlf)<br /> <br /> If Len(strFirstname) > 0 Then<br /> objRS.CursorLocation = adUseServer<br /> objRS.CursorType = adOpenKeyset<br /> objRS.LockType = adLockOptimistic<br /> objRS.Open "students", objConn, , , adCmdTable<br /> objRS.AddNew<br /> objRS("name") = strFirstname<br /> <br /> objRS.Update<br /> <br /> objRS.Close<br /> End If<br />End If<br /><br /><br />%><br /><br />Any suggestions?<br />
|