C
Chris
Hi,
We have an application where users must fill the same form several times,
creating each time a record in the database.
When checking the checkbox in this form means the last record.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim connection As SqlConnection
etc ....
connectionstr = "Data Source=LAPTOP\SQLEXPRESS;Initial
Catalog=mydb;Integrated Security=True"
etc ....
comd.CommandText = "insert into [dbo].[mytable] (field1, field2, etc ...)
values(......);"
connection.Open()
comd.ExecuteNonQuery()
....
If CheckBox1.Checked Then
Server.Transfer("other.aspx")
end if
connection.Close()
end sub
My question is: do i have to close the connection like this or leaving it
open till the last record is inserted?
With other words: where to place the "connection.Close()"? Inside the "If
CheckBox1.Checked Then" or outside it?
Thanks for your advice.
Chris
We have an application where users must fill the same form several times,
creating each time a record in the database.
When checking the checkbox in this form means the last record.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim connection As SqlConnection
etc ....
connectionstr = "Data Source=LAPTOP\SQLEXPRESS;Initial
Catalog=mydb;Integrated Security=True"
etc ....
comd.CommandText = "insert into [dbo].[mytable] (field1, field2, etc ...)
values(......);"
connection.Open()
comd.ExecuteNonQuery()
....
If CheckBox1.Checked Then
Server.Transfer("other.aspx")
end if
connection.Close()
end sub
My question is: do i have to close the connection like this or leaving it
open till the last record is inserted?
With other words: where to place the "connection.Close()"? Inside the "If
CheckBox1.Checked Then" or outside it?
Thanks for your advice.
Chris