tonyboy Posted February 28, 2006 Share Posted February 28, 2006 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 Link to comment Share on other sites More sharing options...
aspnetguy Posted February 28, 2006 Share Posted February 28, 2006 what does the connection string look like? Try posting hte whole code so we can see what context your snippet is in.also are you doing asp.net or asp, there is a difference.The code you provided is asp not asp.net Link to comment Share on other sites More sharing options...
tonyboy Posted February 28, 2006 Author Share Posted February 28, 2006 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 %> Link to comment Share on other sites More sharing options...
aspnetguy Posted February 28, 2006 Share Posted February 28, 2006 The error is in your connection string. It is unable to connect to your oracel database.Can you post the connect string please. Link to comment Share on other sites More sharing options...
tonyboy Posted February 28, 2006 Author Share Posted February 28, 2006 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 Link to comment Share on other sites More sharing options...
aspnetguy Posted February 28, 2006 Share Posted February 28, 2006 It does look fine but the error message is saying it cannot connect. Check your servers ODBC drivers to make sure you can connect to Oracle...or even better download the latest Oracle ODBC Drivers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now