1
Answer

load data in datagridview control

Dipa Ahuja

Dipa Ahuja

15y
4.4k
1
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)
1
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 7y
There are many ways to do it:
 
Use C# code:
 
https://github.com/xoofx/NUglify
 
https://www.codeproject.com/Tips/477066/Extract-inner-text-from-HTML-using-Regex
 
https://consultrikin.wordpress.com/2013/02/21/c-get-plain-text-from-html-string/
 
Use javascript
 
https://ourcodeworld.com/articles/read/376/how-to-strip-html-from-a-string-extract-only-text-content-in-javascript 
Accepted