string strConnection = ConfigurationManager.ConnectionStrings["Database1Entities"].ConnectionString; using (var conn = new SqlCeConnection(string.Format("Data Source=Database1.sdf;", strConnection))) { conn.Open(); try { SqlCeCommand dbCmd = new SqlCeCommand(); String sqlAddNew = "INSERT INTO tbl_Credantials (password,username ) Values(@password,@username)"; dbCmd = new SqlCeCommand(sqlAddNew, conn); dbCmd.Parameters.Add("@password", SqlDbType.NVarChar).Value = txtuserID.Text; dbCmd.Parameters.Add("@username", SqlDbType.NVarChar).Value = txtUsername.Text; dbCmd.ExecuteNonQuery(); } catch (SqlCeException) { throw; } finally { if (conn.State == ConnectionState.Open) conn.Close(); } }
<configuration> <connectionStrings> <add name="Database1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlServerCe.3.5;provider connection string="Data Source=|DataDirectory|\Database1.sdf"" providerName="System.Data.EntityClient" /> </connectionStrings> </configuration>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)