HI , Daniweb

i have two tables Guarantor and Loan1. when i insert into Guarantor all the values for table is inserted except stud_id which is the foreign key for this table from student_tb table. The value for stud_id shows 0 or zero.

EX of code:

if request.QueryString("id")<>"" then

stud_id = request.QueryString("id")

end if

conn.Execute " insert into Guarantor values('" & stud_id & "', '" & guarantor & "', '" & relation & "', '" & IC & "', '" & birth & "','" & age & "','" & citizen & "','" & work & "','" & salary & "', '" & phone & "','" & hse_add & "','" & office_add & "','" & office_phone & "','" & office_fax & "', '" & guarantor1 & "', '" & relation1 & "', '" & IC1 & "','" & birth1 & "','" & age1 & "','" & citizen1 & "','" & work1 & "','" & salary1 & "','" & phone1 & "','" & hse_add1 & "','" & office_add1 & "','" & office_phone1 & "','" & office_fax1 & "')"

rs1.Open " select * from Guarantor where stud_id = '" & stud_id & "'", conn, 1,2


The same goes for Loan1 table :mad:

if not rs1.EOF then

rs1.MoveLast

end if

s = rs1.Fields("stud_id")

conn.Execute "insert into Loan1 values('" & s & "', '"& st_loan &"', '"& loan1 &"', '"& loan2 &"', '"& loan3 &"','"& loan4 &"','"& loan5 &"','"& st_amt &"','off','off','off','off','off','off','off','off','off','No')"

conn.Execute "update student_tb set loan_approve = ('" & app & "') where stud_id = ('" & s & "')"

Plz help me out !! thank you.

which part of the code is single qoute ? can u specify? Correction stud_id is not primary key for Loan and Guarantors table. THe primary key is Loan_id for loan and g_id for guarantors.

conn.Execute " insert into Guarantor values('" & stud_id & "'

this part.

although it shouldn't matter, it is just unnecessary.

if I had to guess then I would say that this .....

if request.QueryString("id")<>"" then

stud_id = request.QueryString("id")

end if

.... is not executing

I would do a little debugging to see if it is.

Also, I would run profiler and look at exactly what sql server is receiving. That should help you determine whether the problem lies in the database or the asp code

Thanks joe for ur help , anyway i fixed it like this .

loanid = request.Form("loanid")
gid = request.Form("gid")
stuid = request.Form("stud_id")

if request.QueryString("id")<>"" then
s = request.QueryString("id")
end if

conn.Execute " insert into Guarantor values('" & stuid & "', '" & guarantor & "', '" & relation & "', '" & IC & "', '" & birth & "','" & age & "','" & citizen & "','" & work & "','" & salary & "', '" & phone & "','" & hse_add & "','" & office_add & "','" & office_phone & "','" & office_fax & "', '" & guarantor1 & "', '" & relation1 & "', '" & IC1 & "','" & birth1 & "','" & age1 & "','" & citizen1 & "','" & work1 & "','" & salary1 & "','" & phone1 & "','" & hse_add1 & "','" & office_add1 & "','" & office_phone1 & "','" & office_fax1 & "')"

rs1.Open " select * from Guarantor where stud_id = '" & stuid & "'", conn, 1,2

if not rs1.EOF then
rs1.MoveLast
end if

conn.Execute "insert into Loan1 values('" & stuid & "', '"& st_loan &"', '"& loan1 &"', '"& loan2 &"', '"& loan3 &"','"& loan4 &"','"& loan5 &"','"& st_amt &"','off','off','off','off','off','off','off','off','off','No')"

conn.Execute "update student_tb set loan_approve = ('" & app & "') where stud_id = ('" & stuid & "')"

This article has been dead for over six months. Start a new discussion instead.