Associate
- Joined
- 6 Oct 2008
- Posts
- 41
Hi folks,
I'm creating a windows application and looking at using SQL Compact as the database.
I've created a compact database and am wanting to create tables and insert records, I've found articles to help me do this. I get no errors, but when the I quit the application and look at the database no tables are showing in the server explorer or SSMS
This is the code I am using:
This is the SQL syntax, which looks all in order:
I'm creating a windows application and looking at using SQL Compact as the database.
I've created a compact database and am wanting to create tables and insert records, I've found articles to help me do this. I get no errors, but when the I quit the application and look at the database no tables are showing in the server explorer or SSMS

This is the code I am using:
Code:
public void CreateTable(string table, string course)
{
SqlCeConnection cn = new SqlCeConnection(AttainmentCalculator.Properties.Settings.Default.dbAttainmentConnectionString);
SqlCeCommand cmdTable = new SqlCeCommand();
string sSQL = "CREATE TABLE " + table + "_" + course + " (" +
"" + table + "ID int IDENTITY PRIMARY KEY, " +
"STUDENT_REF int, " +
"YEAR int, " +
"PRIOR_QUAL nvarchar(150), " +
"GRADE nvarchar(10), " +
"QCA_POINTS int, " +
"STATUS nchar)";
cmdTable = new SqlCeCommand(sSQL, cn);
cn.Open();
try
{
cmdTable.ExecuteNonQuery();
}
catch (SqlCeException sqlexception)
{
MessageBox.Show(sqlexception.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
cn.Close();
}
}
This is the SQL syntax, which looks all in order:
Code:
CREATE TABLE PQ_ACXX02 (PQID int IDENTITY PRIMARY KEY, STUDENT_REF int, YEAR int, PRIOR_QUAL nvarchar(150), GRADE nvarchar(10), QCA_POINTS int, STATUS nchar)