Wednesday, 7 August 2013

Connect local database c#

Connect local database c#

I want to create a empty local database inside my project's folder and
I've error: "An unhandled exception of type
'System.Data.SqlServerCe.SqlCeException' occurred in
System.Data.SqlServerCe.dll" in conn.Open();
I'm lost with what I need to do... I try a lot of possibilities and this
one of them...
SqlCeConnection conn = null;
try
{
conn = new SqlCeConnection("Data Source = bd-avalia.sdf;
Password ='<asdasd>'");
conn.Open();
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "create table cliente(id_cliente int
identity not null primary key, nome varchar not null, password
not null int)";
cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}

No comments:

Post a Comment