Hi All, I have encountered problem with form submission again when inserting data to database via form. The error msg is below: error '80004005' Unspecified error /MassReg/AddSession.asp, line 244 Problem is at this line: rs.open "select * from Session",conn,1,3 Pls see the code attached My Database is: BRANCH_name=Text Year=Text BLK=Text SessionLevel=Text TimeFrom=Text TimeTo=Text The strange thing is it work for another form but not this form. Is that something wrong with my coding? Pls help..
ok, first-off you ought to reorganise the code. Put the failing stuff into a sub called doAdd or whatever and at the start of your page have if Request.QueryString("add")="yes" then doAdd response.redirect("backtowhereicamefrom.asp") end if That way you're not rewriting the whole page for an update. Then again you might want to do that, your choice. It would also be better used to use a hidden field and request.form("add") as it's marginally more secure. I would guess the sql error is related to your already having used the connection. Try closing and then reopening it, or establish a second connection. Or just follow the advice above and it won't already have been used.
Hi All, As advised I have add in the code into subroutine but it still show error in rs.open "select * from Session",conn,1,3 I wonder where go wrong? The problem is sometime it will work in this form but as I create another similar form, it doesn't.. Pls help thks
you need to update your self bcz you dont have basic knowlage of asp pls read any fundamental book of asp
i have already given add code for that now you would like to edit record when you are update code add that time you need 1 unique record id(primary key ) save primary key value in hidden textbox when you submit button press at that time primary value also pass you get primary key value id=request("id") if id="" then id=-1 end if rs.open "select * from tblName where id="&id&" if id<>"" then else rs.addnew end if rs("fildname")=values rs("fildname")=values rs("fildname")=values rs("fildname")=values rs.update rs.close
very interesting but I don't see the relevance to the problem at hand. "select * from Session" is just as valid as "select * from Session where id = 123" The question is, why is that sql throwing an error.
In this example we are using ADO to update an existing record. The SQL statement is the key and by changing that you can update whatever record you want to. This is just an example to get you started. <% ID = 7 %> <% NAME = "Joe Smoe" %> <% MESSAGE = "This is another test" %> <% ' declaring variables ' not neccesary but a good habit Dim DataConn Dim CmdUpdateRecord Dim MYSQL Set DataConn = Server.CreateObject("ADODB.Connection") Set CmdUpdateRecord = Server.CreateObject("ADODB.Recordset") ' The line below shows how to use a system DSN instead of a DNS-LESS connection ' DataConn.Open "DSN=System_DSN_Name" DataConn.Open "DBQ=" & Server.Mappath("../_database/database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};" MYSQL = "SELECT some_table.* FROM some_table WHERE (ID = " & ID & ")" CmdUpdateRecord.Open MYSQL, DataConn, 1, 3 CmdUpdateRecord.Fields("NAME") = NAME CmdUpdateRecord.Fields("MESSAGE") = MESSAGE CmdUpdateRecord.Update ' closing objects and setting them to nothing ' not neccesary but a good habit CmdUpdateRecord.Close Set CmdUpdateRecord = Nothing DataConn.Close Set DataConn = Nothing %> Code (markup): http://www.powerasp.com/content/database/default.asp try this link for add update and delete record