Dipa Ahuja

Dipa Ahuja

  • NA
  • 3.1k
  • 714.3k

load data in datagridview control

Jan 21 2010 5:07 AM
hello i want to load data in datagridview control :

20100121_154215.jpg


n when i click on show button:

code for dat is :
 
string con = "Server=.\\SQLEXPRESS;Database=db1.mdf;Trusted_Connection=True;";

 SqlDataAdapter da = new SqlDataAdapter();


private void btnshow_Click(object sender, EventArgs e)
{
            string q = "select * from items where cname= " + "'"      +comboBox1.SelectedValue.ToString() + "'";
           
            textBox1.Text = comboBox1.SelectedValue.ToString();

            da = new SqlDataAdapter(q, con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dataGrid1.DataSource = ds;

 }




bt i get error at runtime on the statement

da.Fill(ds);
Error:Error
Unable to copy file "D:\WindowsApplication2\WindowsApplication2\db1_log.ldf" 
to "bin\Debug\db1_log.ldf".
The process cannot access the file 'D:\WindowsApplication2\WindowsApplication2\db1_log.ldf' 
because it is being used by another process.	WindowsApplication2

N when i stop the program this error continue to occur while building.. 

but when i restart my computer this error gone..

whts the reason??


Answers (1)