Hi,
I am wondering if code below is right. Is there any unnecessary line?
Thanks

<%
on error resume next
ad=request.form("name")

Set RcSet = Server.CreateObject("ADODB.RecordSet")
sql = "Insert Into veriler (name) Values ('"&name&"')"         'ADD
sql = "Update veriler Set name='"&name&"' Where id=1"    'UPDATE
sql = "Delete From veriler Where id=1"                                'DELETE
RcSet.open sql, conn, 1, 3				
RcSet.execute (sql)

if err.number=0 then
	Response.write "Added."
else
	response.write "Error"
end if

RcSet.close
Set RcSet = nothing
conn.close
Set conn=nothing
%>

There is a couple of unnecessary lines here.

sql = "Insert Into veriler (name) Values ('"&name&"')" 'ADD
sql = "Update veriler Set name='"&name&"' Where id=1" 'UPDATE
sql = "Delete From veriler Where id=1" 'DELETE

Here you will end up with only "Delete From veriler Where id=1"

Because you replace the insert and the Update with the Delete.
If you whould like to insert, update and delete you need to rewrite it to:

sql = "Insert Into veriler (name) Values ('"&name&"');"
sql = sql & "Update veriler Set name='"&name&"' Where id=1;"
sql = sql & "Delete From veriler Where id=1"

Also notice that i added ; to seperate each query to the server.
You can either use ; or you can run the querys one by one with a execute on each. Using ; is fastet, booth in coding time and execution time on the SQL server.

Apart from SQL statements (Should be one anyway), is there any unnecessary code there?

I mean are therese 2 lines necessary.

RcSet.open sql, conn, 1, 3				
RcSet.execute (sql)

I only want to know this.

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.