Hi there. A tip for you to get the most help from forums. You need to point out what line 105 is. If your code had been 200 lines long I would not have looked at it. If you point out the offending line of code its very easy for people tot help you....
Also if the offending line can be written to the browser. Write it, run the browser and also post it also.
The most obvious mistake in your code is not closing the ASP delimiter after the 'select * from jenny' line and before the 'Student name:'
What else have I done to your code:
- your fix string function is a bit weak. You should use the one I have given you below it does a bit more. Its fairly obvious what the changes do
- It a good practice to always place a trailing semicolon after all SQL statements
- Sorry, I just don't like your spaces inside the round brackets however this will not cause error
Code:
<%
Function fixStr(theString)
fixStr = ""
fixStr = CStr(theString)
if(len(fixStr) > 0) Then
fixStr = Replace(fixStr, """", """, 1, -1, 1)
fixStr = Replace(fixStr, "'", "''", 1, -1, 1)
fixStr = Replace(fixStr, vbCrLf, "<BR>", 1, -1, 1)
end if
End Function
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open strConnect
sqlString = "select * from jenny where ID = " & ID & ";"
%>
Student name: <input type="text" name="name" value="<%=Student_name%>"><br />
Country: <input type="text" name="country" value="<%=country%>"><br />
Phone: <input type="text" name="phone" value="<%=phone%>"><br />
Email: <input type="text" name="email" value="<%=email%>"><br />
<%
sqlString = "update jenny set " &_
"Student name ='" & fixStr(Student_name) & "', " &_
"Country ='" & fixStr(Country) & "', " &_
"Phone ='" & fixStr(Phone) & "', " &_
"Email ='" & fixStr(Email) & "' where ID =" & ID & ";"
dbCon.Execute sqlString
%>
So, run this code. You error is more than likely in your second SQL statement since you are not even executing the first one!. place a response.write sqlString underneath the statment. make sure this is before the .execute. Then run the browser. Post the offending sql. I would say there is an issue with one of the values in your variables