PDA

View Full Version : بازیابی داده ها از دیتا بیس ونمایش در دیتا گرید



Bahar_HS
دوشنبه 08 مهر 1387, 09:51 صبح
با سلام
فرمی که در(C#) ایجاد کردم از طریق کنترلهای مختلفی که روی فرم قرار داره،مثل(textBox,comboBox,radioButton,...) مشخصات کاربر رو می گیره و در جدولی که در(Sql Server 2000) هست ذخیره می کنه،

می خوام فرم آیتم "بازیابی" داشته باشه، یعنی همه ی رکوردهای ذخیره شده در دیتا بیس،
در(Sql server) ، بازیابی بشه ودر DataGridView که روی فرم قرار دادم ، نمایش داده بشه، که البته امکان ویرایش و حذف رکوردها هم باشه،

این کد رو نوشتم ولی کاری انجام نمیشه،
لطفا منو راهنمایی کنید.



private void Baz_Click(object sender, EventArgs e)
{
con = new SqlConnection("Data Source = (local);Initial Catalog = karamuzy ;Integrated Security=True ");
con.Open();
// 1. instantiate a new DataSet
myDataSet = new DataSet();

// 2. init SqlDataAdapter with select command and connection
myDataAdapter = new SqlDataAdapter("select name,family,degree,degreerr,khedmatm,khedmat,start day,startmounth,startyear,numbershe,birthday,birth mounth,birthyear,birth,namefather from Table1 WHERE finishday = Null and finishmounth = Null and finishyear = Null", con);

// 3. fill in insert, update, and delete commands
// 4. fill the dataset
myDataAdapter.Fill(myDataSet, "Table1DataSet");
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(myDataAdapter);

myDataGrid.DataSource = myDataSet;
myDataGrid.DataMember = "Table1";

myDataAdapter.Update(myDataSet, "Table1DataSet");
con.Close();

}

Bahar_HS
سه شنبه 09 مهر 1387, 06:00 صبح
کسی منو راهنمایی نمی کنه؟؟؟؟ :افسرده: :ناراحت: