Note that there are some explanatory texts on larger screens.

plurals
  1. POsql only creates one table
    text
    copied!<p>I have a section of code dedicated to creating several tables, yet it creates the first one then throws exceptions, but the exception contains nothing, its blank. Here is my code:</p> <pre><code>string connectionString = "DataSource=\"EventControl.sdf\""; SqlCeEngine en = new SqlCeEngine(connectionString); en.CreateDatabase(); string createTable = "CREATE TABLE Login (userName nvarchar(50), UserType nvarchar(10), Salt nvarchar(100), Hash nvarchar(100))"; string connection = "Data Source =\"EventControl.sdf\""; SqlCeConnection connexion = new SqlCeConnection(connection); SqlCeCommand table = new SqlCeCommand(createTable, connexion); try { connexion.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } table.ExecuteNonQuery(); connexion.Close(); string createTable1 = "CREATE TABLE Logs (LogNo nvarchar(5), LoggedBy nvarchar(20), DateAndTime nvarchar(20), Callsign nvarchar(20), Category nvarchar(20), SubCategory nvarchar(20), Escalated nvarchar(15), Summary nvarchar(MAX), Complete nvarchar(10))"; string connection1 = "Data Source =\"EventControl.sdf\""; SqlCeConnection connexion1 = new SqlCeConnection(connection1); SqlCeCommand table1 = new SqlCeCommand(createTable1, connexion1); try { connexion1.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } table1.ExecuteNonQuery(); connexion1.Close(); string createTable2 = "CREATE TABLE Sites (SiteName nvarchar(100),SiteAddress nvarchar(100),PersonInCharge nvarchar(100))"; string connection2 = "Data Source =\"EventControl.sdf\""; SqlCeConnection connexion2 = new SqlCeConnection(connection2); SqlCeCommand table2 = new SqlCeCommand(createTable2, connexion2); try { connexion2.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } table2.ExecuteNonQuery(); connexion2.Close(); string createTable3 = "CREATE TABLE Categories (Category nvarchar(50), SubCategory nvarchar(50))"; string connection3 = "Data Source =\"EventControl.sdf\""; SqlCeConnection connexion3 = new SqlCeConnection(connection3); SqlCeCommand table3 = new SqlCeCommand(createTable3, connexion3); try { connexion3.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } table3.ExecuteNonQuery(); connexion3.Close(); string createTable4 = "CREATE TABLE Callsigns (StaffName nvarchar (50), Callsign nvarchar(50))"; string connection4 = "Data Source =\"EventControl.sdf\""; SqlCeConnection connexion4 = new SqlCeConnection(connection4); SqlCeCommand table4 = new SqlCeCommand(createTable4, connexion4); try { connexion4.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } table4.ExecuteNonQuery(); connexion4.Close(); string createTable5 = "CREATE TABLE Events (EventName nvarchar(100), EventLocation nvarchar(100), PersonInCharge nvarchar(100))"; string connection5 = "Data Source =\"EventControl.sdf\""; SqlCeConnection connexion5 = new SqlCeConnection(connection5); SqlCeCommand table5 = new SqlCeCommand(createTable5, connexion5); try { connexion5.Open(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } table5.ExecuteNonQuery(); connexion5.Close(); </code></pre> <p>It gets to table1.ExecuteNonQuery then stops. Can anyone help??</p> <p>PS And before anyone says why not just create the databases in VS, its because i have tried that, and they worked fine on my computer but when i created the setup files for deployment the folders got all messed up and the program wouldnt recognise the DB anymore</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload