@@ -59,6 +59,8 @@ public DataSet GetCatalogData()
5959 {
6060 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
6161 {
62+ connection . Open ( ) ;
63+
6264 SqliteDataAdapter da = new SqliteDataAdapter ( "select * from Products" , connection ) ;
6365 DataSet ds = new DataSet ( ) ;
6466
@@ -79,6 +81,8 @@ public bool IsValidCustomerLogin(string email, string password)
7981
8082 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
8183 {
84+ connection . Open ( ) ;
85+
8286 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
8387
8488 //TODO: User reader instead (for all calls)
@@ -132,6 +136,8 @@ public string CustomCustomerLogin(string email, string password)
132136
133137 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
134138 {
139+ connection . Open ( ) ;
140+
135141 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
136142 DataSet ds = new DataSet ( ) ;
137143 da . Fill ( ds ) ;
@@ -179,6 +185,8 @@ public string GetCustomerEmail(string customerNumber)
179185
180186 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
181187 {
188+ connection . Open ( ) ;
189+
182190 string sql = "select email from CustomerLogin where customerNumber = " + customerNumber ;
183191 SqliteCommand command = new SqliteCommand ( sql , connection ) ;
184192 output = command . ExecuteScalar ( ) . ToString ( ) ;
@@ -204,6 +212,8 @@ public DataSet GetCustomerDetails(string customerNumber)
204212
205213 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
206214 {
215+ connection . Open ( ) ;
216+
207217 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
208218 da . Fill ( ds ) ;
209219 }
@@ -224,6 +234,8 @@ public DataSet GetOffice(string city)
224234
225235 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
226236 {
237+ connection . Open ( ) ;
238+
227239 string sql = "select * from Offices where city = @city" ;
228240 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
229241 da . SelectCommand . Parameters . AddWithValue ( "@city" , city ) ;
@@ -237,6 +249,8 @@ public DataSet GetComments(string productCode)
237249 {
238250 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
239251 {
252+ connection . Open ( ) ;
253+
240254 string sql = "select * from Comments where productCode = @productCode" ;
241255 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
242256 da . SelectCommand . Parameters . AddWithValue ( "@productCode" , productCode ) ;
@@ -279,6 +293,8 @@ public string UpdateCustomerPassword(int customerNumber, string password)
279293
280294 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
281295 {
296+ connection . Open ( ) ;
297+
282298 SqliteCommand command = new SqliteCommand ( sql , connection ) ;
283299
284300 int rows_added = command . ExecuteNonQuery ( ) ;
@@ -304,6 +320,8 @@ public string[] GetSecurityQuestionAndAnswer(string email)
304320
305321 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
306322 {
323+ connection . Open ( ) ;
324+
307325 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
308326
309327 DataSet ds = new DataSet ( ) ;
@@ -328,6 +346,8 @@ public string GetPasswordByEmail(string email)
328346
329347 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
330348 {
349+ connection . Open ( ) ;
350+
331351 //get data
332352 string sql = "select * from CustomerLogin where email = '" + email + "';" ;
333353 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
@@ -356,6 +376,8 @@ public DataSet GetUsers()
356376 {
357377 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
358378 {
379+ connection . Open ( ) ;
380+
359381 string sql = "select * from CustomerLogin;" ;
360382 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
361383 DataSet ds = new DataSet ( ) ;
@@ -369,6 +391,8 @@ public DataSet GetOrders(int customerID)
369391
370392 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
371393 {
394+ connection . Open ( ) ;
395+
372396 string sql = "select * from Orders where customerNumber = " + customerID ;
373397 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
374398 DataSet ds = new DataSet ( ) ;
@@ -390,6 +414,8 @@ public DataSet GetProductDetails(string productCode)
390414
391415 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
392416 {
417+ connection . Open ( ) ;
418+
393419 sql = "select * from Products where productCode = '" + productCode + "'" ;
394420 da = new SqliteDataAdapter ( sql , connection ) ;
395421 da . Fill ( ds , "products" ) ;
@@ -422,6 +448,8 @@ public DataSet GetOrderDetails(int orderNumber)
422448
423449 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
424450 {
451+ connection . Open ( ) ;
452+
425453 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
426454 DataSet ds = new DataSet ( ) ;
427455 da . Fill ( ds ) ;
@@ -437,6 +465,8 @@ public DataSet GetPayments(int customerNumber)
437465 {
438466 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
439467 {
468+ connection . Open ( ) ;
469+
440470 string sql = "select * from Payments where customerNumber = " + customerNumber ;
441471 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
442472 DataSet ds = new DataSet ( ) ;
@@ -469,6 +499,7 @@ public DataSet GetProductsAndCategories(int catNumber)
469499
470500 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
471501 {
502+ connection . Open ( ) ;
472503
473504 sql = "select * from Categories" + catClause ;
474505 da = new SqliteDataAdapter ( sql , connection ) ;
@@ -497,6 +528,8 @@ public DataSet GetEmailByName(string name)
497528
498529 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
499530 {
531+ connection . Open ( ) ;
532+
500533 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
501534 DataSet ds = new DataSet ( ) ;
502535 da . Fill ( ds ) ;
@@ -516,6 +549,8 @@ public string GetEmailByCustomerNumber(string num)
516549
517550 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
518551 {
552+ connection . Open ( ) ;
553+
519554 string sql = "select email from CustomerLogin where customerNumber = " + num ;
520555 SqliteCommand cmd = new SqliteCommand ( sql , connection ) ;
521556 output = ( string ) cmd . ExecuteScalar ( ) ;
@@ -538,6 +573,8 @@ public DataSet GetCustomerEmails(string email)
538573
539574 using ( SqliteConnection connection = new SqliteConnection ( _connectionString ) )
540575 {
576+ connection . Open ( ) ;
577+
541578 SqliteDataAdapter da = new SqliteDataAdapter ( sql , connection ) ;
542579 DataSet ds = new DataSet ( ) ;
543580 da . Fill ( ds ) ;
0 commit comments