At a guess, you are doign something along the lines of:
SqlCEConnection con = new SqlCEConnection("Data Source=C:\Documents and Settings\Hp\My Documents\Visual Studio 2008\Projects\Electionsoft\Electionsoft\electionsoft.sdf;Persist Security Info=True.");
And the compiler is complaining?
Try inserting a '@' character in front of the string:
SqlCEConnection con = new SqlCEConnection(@"Data Source=C:\Documents and Settings\Hp\My Documents\Visual Studio 2008\Projects\Electionsoft\Electionsoft\electionsoft.sdf;Persist Security Info=True.");
This disables escape sequence processing, and lets the '\' character through.
If that isn't the problem, then what error are you getting?
By the way: you should never store passwords in clear text. There is a brief tip here explaining why and what to actually do:
Password Storage: How to do it.[
^]
"this worked thanks, but another thing showed up. I've manually added data to the password database but on trying to retrieve it using
openConnection();
SqlCeCommand cmd;
string command;
try
{
command = "SELECT main_password FROM password WHERE id = 1";
cmd = new SqlCeCommand(command,con);
cmd.CommandType = CommandType.Text;
SqlCeResultSet result = cmd.ExecuteResultSet(ResultSetOptions.Updatable);
passwordtxt = result.GetString(1);
if(passwordtxt.Equals(null))
{
command = "SELECT default_password FROM password WHERE id = 1";
cmd = new SqlCeCommand(command, con);
cmd.CommandType = CommandType.Text;
SqlCeResultSet result2 = cmd.ExecuteResultSet(ResultSetOptions.None);
passwordtxt = result2.GetString(1);
}
}
catch(SqlCeException sqlException)
{
MessageBox.Show(sqlException.Message,"Problem1",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Problem2",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
I got the exception that "No data exits for row/column".
please is there something i'm missing. thanks
Really you should open this as a new question.
But: I wouldn't do it that way:
SqlCEConnection con = new SqlCEConnectin(@"Data Source=C:\Documents and Settings\Hp\My Documents\Visual Studio 2008\Projects\Electionsoft\Electionsoft\electionsoft.sdf;Persist Security Info=True.");
con.Open();
SqlCeCommand cmd = new SqlCECommand("SELECT main_password, default_password FROM password WHERE id = 1", con);
try
{
SqlCEDataReader r = com.ExecuteQuery();
if (r.Read())
{
passwordText = (string) r.Rows[0]["main_password"];
}
if (string.IsNullOrEmpty(passwordText))
{
{
passwordText = (string) r.Rows[0]["default_password"];
}
}
catch(SqlCeException sqlException)
{
MessageBox.Show(sqlException.Message,"Problem1",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Problem2",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
finally
{
con.Close();
com.Dispose();
con.Dispose();
}