Jump to content

tonyboy

Members
  • Posts

    3
  • Joined

  • Last visited

tonyboy's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. tonyboy

    sql_insert.asp

    The code to connect with Oracle look fine:Dim objConn, InReplyTo, rsInReplyTo, IsAReplySet objConn = Server.CreateObject("ADODB.Connection")objConn.Open "dsn=ORCL9; uid=toy; pwd=yes;" If Request ("Action") = "Send Message" Then ' We are into the second step: We should be inserting the records now. ' Open a Recordset so that we can insert it into the "Messages" table.Dim rsMessageSet rsMessage = Server.CreateObject ("ADODB.Recordset") Set rsMessage = objConn.Execute ("INSERT INTO MESSAGES (Messageid, PostedBy, Email, Subject, body, InReplyTo) VALUES (forum_seq.nextval, " & varMessageid & "," & varPostedBy & "," & varEmail & "," & varSubject & "," & varBody & "," & varInReplyTo & ")" ' Create a new, blank record. tt.nextval rsMessage.AddNew ' Now set all fields to the values we got from the form. 'rsMessage ("ForumID") = Request ("ForumID") 'rsMessage ("PostedBy") = Request ("PostedBy") 'rsMessage ("Email") = Request ("Email") 'rsMessage ("Subject") = Request ("Subject") 'rsMessage ("Body") = Request ("Body") 'rsMessage ("InReplyTo") = Request ("InReplyTo") 'rsMessage ("Data") = Now ' And save them. rsMessage.Update ' We also need to update the "Last Post on" and "Total Posts" ' for the corresponding forum. Dim rsForum Set rsForum = Server.CreateObject ("ADODB.Recordset") rsForum.Open "SELECT Posts, LastPost FROM Forums WHERE ForumID = " & Request ("ForumID"), objConn, adOpenStatic, adLockPessimistic ' Update the values with the new values: ' Increment "Posts" & set the time of the last post as Now. rsForum ("Posts") = rsForum ("Posts") + 1 rsForum ("LastPost") = Now rsForum.Update ' Set cookies for the "From" and "Email" fields, ' so that the user need not enter them again ' if he sends another message in the same session. ' Cookies are saved only for the session, not permanently. Response.Cookies (SiteTitle)("PostedBy") = Request("PostedBy") Response.Cookies (SiteTitle)("Email") = Request("Email") ' Take the user to the Forum page, so he can see the ' message he just posted. Response.Redirect "forum.asp?ForumID=" & Request ("ForumID")Else ' Else means, we are still in Step1, ' and we should display the form. ' Is this message in reply to some other message, ' or is it an original message? InReplyTo = Request ("InReplyTo") ' "IsAReply" is a Boolean variable that means the following: ' True : This is in reply to a message. ' False : This is an original message. If InReplyTo <> 0 And InReplyTo <> "" Then IsAReply = True Set rsInReplyTo = objConn.Execute ("SELECT * FROM Messages WHERE MessageID = " & InReplyTo) End If ' If it's not a reply, and the ForumID is not supplied, ' then something is wrong. Take the user back. ' Beware, it is NOT an error if this is a reply & the ForumID. ' If we have the original message, we can determine which Forum this belongs to. If Not IsAReply And (Request ("ForumID") = "" Or Request ("ForumID") = 0) Then Response.Redirect "forumora.asp" End If
  2. tonyboy

    sql_insert.asp

    What i'm trying to do is replace the insert code into access database to an insert into oracle database ' Open a Recordset so that we can insert it into the "Messages" table.Dim rsMessageSet rsMessage = Server.CreateObject ("ADODB.Recordset")'Set rsMessage = objConn.Execute ("INSERT into Messages (Messageid) VALUES (forum_seq.nextval)") Set rsMessage = objConn.Execute ("INSERT INTO MESSAGES (Messageid, PostedBy, Email, Subject, body, InReplyTo) VALUES (forum_seq.nextval, " & varMessageid & "," & varPostedBy & "," & varEmail & "," & varSubject & "," & varBody & "," & varInReplyTo & ")"'rsMessage.Open "SELECT * FROM Messages", objConn, adOpenStatic, adLockPessimistic'rsMessage.Open "Messages", objConn, adOpenStatic, adLockPessimistic ' Create a new, blank record. tt.nextval rsMessage.AddNew ' Now set all fields to the values we got from the form. 'This is an insert into access database table 'rsMessage ("ForumID") = Request ("ForumID") 'rsMessage ("PostedBy") = Request ("PostedBy") 'rsMessage ("Email") = Request ("Email") 'rsMessage ("Subject") = Request ("Subject") 'rsMessage ("Body") = Request ("Body") 'rsMessage ("InReplyTo") = Request ("InReplyTo") 'rsMessage ("Data") = Now ' And save them. rsMessage.Update ' We also need to update the "Last Post on" and "Total Posts" ' for the corresponding forum. Dim rsForum Set rsForum = Server.CreateObject ("ADODB.Recordset") rsForum.Open "SELECT Posts, LastPost FROM Forums WHERE ForumID = " & Request ("ForumID"), objConn, adOpenStatic, adLockPessimistic ' Update the values with the new values: ' Increment "Posts" & set the time of the last post as Now. rsForum ("Posts") = rsForum ("Posts") + 1 rsForum ("LastPost") = Now rsForum.Update ' Set cookies for the "From" and "Email" fields, ' so that the user need not enter them again ' if he sends another message in the same session. ' Cookies are saved only for the session, not permanently. Response.Cookies (SiteTitle)("PostedBy") = Request("PostedBy") Response.Cookies (SiteTitle)("Email") = Request("Email") ' Take the user to the Forum page, so he can see the ' message he just posted. Response.Redirect "forum.asp?ForumID=" & Request ("ForumID")Else ' Else means, we are still in Step1, ' and we should display the form. ' Is this message in reply to some other message, ' or is it an original message? InReplyTo = Request ("InReplyTo") ' "IsAReply" is a Boolean variable that means the following: ' True : This is in reply to a message. ' False : This is an original message. If InReplyTo <> 0 And InReplyTo <> "" Then IsAReply = True Set rsInReplyTo = objConn.Execute ("SELECT * FROM Messages WHERE MessageID = " & InReplyTo) End If ' If it's not a reply, and the ForumID is not supplied, ' then something is wrong. Take the user back. ' Beware, it is NOT an error if this is a reply & the ForumID. ' If we have the original message, we can determine which Forum this belongs to. If Not IsAReply And (Request ("ForumID") = "" Or Request ("ForumID") = 0) Then Response.Redirect "forumora.asp" End If %>
  3. tonyboy

    sql_insert.asp

    Hi everyone. This is my first time here. I'm a beginner in asp.net. I have a small problem. I have an ASP Forum connect with microsoft access database. I want replace the access connection to oracle database connection, but i don't have any experience with oracle. What I'm trying to do, is create a new blank record. It musts insert records to the database. The script allows the user send messages to the others. I want change the code to connect to oracle database. This code below makes an insert into messages table in my oracle database:Dim rsMessageSet rsMessage = Server.CreateObject ("ADODB.Recordset")Set rsMessage = objConn.Execute ("INSERT into Messages (Messageid, Subject) VALUES (forum_seq.nextval, " & Request ("Subject") & ")")But i receive a error message which says:Error Type:Microsoft OLE DB Provider for ODBC Drivers (0x80004005)[Oracle][ODBC][Ora]ORA-00936: missing expression/BT/post.asp, line 26Is there anyone who have done this before or anyone who knows how we do this?Best regardsTony
×
×
  • Create New...