21-02-19, 09:08 AM
السلام عليك
يسعد الله اوقاتكم
عندي استفسار عن طريقه الاتصال واغلاق الاتصال بقاعدة البيانات
الكود الي عندي يعمل بحث في القاعدة اكثر من مره
كذا
\
مثل ما ضاهر يعمل فحص اكثر من مره
في البدايه لازم افتح الاتصال
ولاكن هل اغلق الاتصال مع كل فحص او في اخر فحص
جربت اغلق الاتصال في كل فحص بس طلع مشكله
وجربت اغلق الاتصال في الاخير وطلع مشكله
ما هو الشي الصحيح بارك الله فيكم
يسعد الله اوقاتكم
عندي استفسار عن طريقه الاتصال واغلاق الاتصال بقاعدة البيانات
الكود الي عندي يعمل بحث في القاعدة اكثر من مره
كذا
\
كود :
Dim str As String = String.Format("Data Source= C:\LOG\DB{0}.s3db; version=3;Pooling=True;Synchronous=Off;journal mode=Memory", strcallbk)
Dim con As New SQLiteConnection(str)كود :
con.Open()
Dim cmd41 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE CALLop = @CALLop", Stadd), con)
cmd41.Parameters.AddWithValue("CALLop", Trim(a3))
Dim rowCount41 As Integer = Convert.ToInt32(cmd41.ExecuteScalar())
If rowCount41 <> 0 Then
c1 = "QSO B"
Else
c1 = "NEW ON"
End If
Dim cmd412 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE CALLop = @CALLop and bands = @bands", Stadd), con)
cmd412.Parameters.AddWithValue("CALLop", Trim(a3))
cmd412.Parameters.AddWithValue("bands", Trim(bandsxxs))
Dim rowCount412 As Integer = Convert.ToInt32(cmd412.ExecuteScalar())
If rowCount412 <> 0 Then
c1 = "QSO B"
Else
c1 = "NEW BAND"
End If
Dim cmd413 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE CALLop = @CALLop and modes = @modes", Stadd), con)
cmd413.Parameters.AddWithValue("CALLop", Trim(a3))
cmd413.Parameters.AddWithValue("modes", Trim(modesCXXX))
Dim rowCount413 As Integer = Convert.ToInt32(cmd413.ExecuteScalar())
If rowCount413 <> 0 Then
c1 = "QSO B"
Else
c1 = "NEW MODE"
End If
Dim cmd414 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE country = @country", Stadd), con)
cmd414.Parameters.AddWithValue("country", Trim(country.Text))
Dim rowCount414 As Integer = Convert.ToInt32(cmd414.ExecuteScalar())
If rowCount414 <> 0 Then
Else
c1 = "NEW Country"
End If
con.Close()مثل ما ضاهر يعمل فحص اكثر من مره
في البدايه لازم افتح الاتصال
كود :
con.Open()ولاكن هل اغلق الاتصال مع كل فحص او في اخر فحص
جربت اغلق الاتصال في كل فحص بس طلع مشكله
كود :
con.Open()
Dim cmd41 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE CALLop = @CALLop", Stadd), con)
cmd41.Parameters.AddWithValue("CALLop", Trim(a3))
Dim rowCount41 As Integer = Convert.ToInt32(cmd41.ExecuteScalar())
If rowCount41 <> 0 Then
c1 = "QSO B"
Else
c1 = "NEW ON"
End If
con.Close()
con.Open()
Dim cmd412 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE CALLop = @CALLop and bands = @bands", Stadd), con)
cmd412.Parameters.AddWithValue("CALLop", Trim(a3))
cmd412.Parameters.AddWithValue("bands", Trim(bandsxxs))
Dim rowCount412 As Integer = Convert.ToInt32(cmd412.ExecuteScalar())
If rowCount412 <> 0 Then
c1 = "QSO B"
Else
c1 = "NEW BAND"
End If
con.Close()
con.Open()
Dim cmd413 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE CALLop = @CALLop and modes = @modes", Stadd), con)
cmd413.Parameters.AddWithValue("CALLop", Trim(a3))
cmd413.Parameters.AddWithValue("modes", Trim(modesCXXX))
Dim rowCount413 As Integer = Convert.ToInt32(cmd413.ExecuteScalar())
If rowCount413 <> 0 Then
c1 = "QSO B"
Else
c1 = "NEW MODE"
End If
con.Close()
con.Open()
Dim cmd414 As New SQLiteCommand(String.Format("SELECT * FROM DB{0} WHERE country = @country", Stadd), con)
cmd414.Parameters.AddWithValue("country", Trim(country.Text))
Dim rowCount414 As Integer = Convert.ToInt32(cmd414.ExecuteScalar())
If rowCount414 <> 0 Then
Else
c1 = "NEW Country"
End If
con.Close()وجربت اغلق الاتصال في الاخير وطلع مشكله
كود :
Connection was closed, statement was terminated vb.netما هو الشي الصحيح بارك الله فيكم
