DB Path: C:\Users\Ali\Documents\Visual Studio 2010\Projects\UCS\unitsdb.sdf
Table: tblAcceleration
Fields: fldUnitName (nvarchar), fldCoefficient (float)
What I Need: Codes (namespaces, connection, sql query...) which give me the fldCoefficient value for a specified fldUnitName (example: WHERE fldUnitName="centigal"). And finally give the result to a label.
Thanks in advance.
My table's preview:

Sudhakar ChaudharyPosted Jan 6, 2013, 8:57 AM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace sdf
{
public partial class Form1 : Form
{
SqlCeConnection connection = new SqlCeConnection();
string DB_path;
SqlCeDataAdapter adp;
DataSet ds = new DataSet();
public Form1()
{
InitializeComponent();
DB_path = Application.StartupPath.ToString();
connection.ConnectionString = "data source=" + DB_path + "\\unitsdb.sdf";
}
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.Rows.Clear();
adp = new SqlCeDataAdapter("SELECT [ fldUnitName], fldCoefficient FROM tblAcceleration WHERE([ fldUnitName] = '"+textBox1.Text+"')", connection);
adp.Fill(ds, "s");
dataGridView1.DataSource = ds.Tables["s"];
}
}
}