Odpovědět how to insert a record from mobile application into database?

  • 29. dubna 2007 15:37
     
     
    HI, 
    I am making a project for pocket pc in VS 2005. It is a university's website not a actual website but a demonstration of my project. I want my users to give their name and address using this website to order a prospectus. So when I deploy my application and insert name and address from application which should go into my database I created in SQL server Mobile edition named as university.sdf. The record does not go into the database. I refreshed the database. I am watching the same database which is running but it is not showing the record in the datatable. I am sending you a copy of my code.

          private void btnSubmit_Click(object sender, EventArgs e)
           {
               SqlCeConnection con = new SqlCeConnection();
               con.ConnectionString = ("Data Source = "
                                      + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\university.sdf;"));

               SqlCeCommand cmdAddPros = new SqlCeCommand();
               cmdAddPros.Connection = con;
               cmdAddPros.CommandText = String.Format("insert into ProspectiveStudent (Name,Address,PostCode) Values('{0}','{1}','{2}')", txtName.Text, txtAddress.Text, txtPostCode.Text);
               con.Open();

               int intcount = cmdAddPros.ExecuteNonQuery();
               con.Close();




           }
    if anyone can help me I will be grateful

Odpovědi

Všechny reakce