PDA

View Full Version : دیتا گرید و اتصال داده به آن



faramarz_s
دوشنبه 28 مهر 1382, 16:15 عصر
private void Form1_Load(object sender, System.EventArgs e)
{
//SqlDataReader oReader = null;
SqlConnection oConnection = null;
oConnection = new
SqlConnection("server=localhost;uid=sa;pwd=yaali;database=FaraLin kCenter");

string sSelectSQL = "SELECT id as Name FROM tblDataGrid";
SqlCommand oCommand = new SqlCommand(sSelectSQL,oConnection);

SqlDataAdapter da = new SqlDataAdapter("Select * from tblDataGrid", oConnection);
//open the connection, and use the reader to populate the combobox
oConnection.Open();
//oReader = oCommand.ExecuteReader();

DataSet ds = new DataSet();
// fill dataset
da.Fill(ds, "tblDataGrid");// write dataset contents to an xml file by calling WriteXml method
// Attach DataSet to DataGrid
dataGrid1.DataSource = ds.DefaultViewManager; }



Could not copy temporary files to the output directory.
The file 'WindowsApplication1.exe' cannot be copied to the run directory. The process
cannot access the file because it is being used by another process.
The file 'WindowsApplication1.pdb' cannot be copied to the run directory. The process cannot access the file because it is being used by another process.

Vahid_Nasiri
دوشنبه 28 مهر 1382, 21:29 عصر
خظای شما به این معنا است که یکبار برنامه را اجرا کرده اید و هنگ کرده است سپس قصد دارید یکبار دیگر برنامه را کامپایل کنید. این اجازه را به شما نمی دهد چون نمی تواند فایل exe جدید را روی قدیمی ایجاد کند چون هنوز در حال مصرف است. پس باید یکبار سیستم را ریست کنید. حتی task manager هم جواب نمی دهد و فقط ریست .....

faramarz_s
سه شنبه 29 مهر 1382, 07:25 صبح
در مورد کدنویسی مشکلی نیست؟

Vahid_Nasiri
سه شنبه 29 مهر 1382, 21:02 عصر
کد را اجرا کنید. متوجه خواهید شد :wink: