I asked a question [HERE] and we got all the information stored in the database SQL Server CE database.
The question remains now how to get the information stored back into variables.
This line of code:
myReader.SqlCeReader();
will not compile, I am asked if I have missed a compiler reference what ever that is.
The information is stored as strings with an Integer “ID” primary key.
The information will be used to create shortcuts on a disk suitable for launching, images in paint, executable programs and so on. They should not be more than strings which is why I find it hard to do, it should be simple.
A sample record
id=int NstacksName=String NstacksPath=String.
I think I have it all wrong and am surprised it even compiles this far.
private void label2_Click(object sender, EventArgs e)
{
string DirName;
SqlCeConnection conn = new SqlCeConnection("Data Source=C:\\Users\\username\\Documents\\Visual Studio 2010\\Projects\\NStacks1\\NStacks1\\Database1.sdf");
String name;
try
{
conn.Open();
SqlCeCommand Command = new SqlCeCommand("SELECT * FROM NStacks1 WHERE ID = 1", conn);
DataTable Data = new DataTable();
SqlCeDataAdapter adapter = new SqlCeDataAdapter(Command);
SqlCeDataReader myReader;
try
{
myReader.SqlCeReader();
DirName = Data.ToString();
con.Close();
name = DirName;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
con.Close();
}
}