aleksandar ruba

aleksandar ruba

  • NA
  • 33
  • 25.5k

winform and database

Oct 2 2012 4:15 AM
Hy,i wont to do winform app and the problem is database.I must put the database in aplication folder so when the aplication is instaled the database must be conected with aplication wherever is instaled and to avoid a problem if the client pc don't have instaled server or other stuff to run database.I wont to ask which database is good for this,i try to create database in visual studio 2010 but i can't get connection because my conneection string i think is not good.
I thing the soluction with |DataDirectory| is good but it don't work for me.

I try this but is not work

 string spoj = @"Data Source=|DataDirectory|\baza.sdf; Persist Security Info=False;";
           
            SqlConnection konekcija = new SqlConnection(spoj);
            konekcija.Open(); 
            string upit="select * from osoba";
            SqlDataAdapter da = new SqlDataAdapter(upit, konekcija);
            DataSet ds = new DataSet();
            da.Fill(ds, "osoba");
            dataGridView1.DataSource = ds.Tables["osoba"];

If you can advice me i be grateful.  

Answers (1)