Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am doing project. I want to list in listview but I dont do.

How can I do?
C#
try
{
    FbConnection con = new FbConnection("connectionString");
    con.Open();

    FbCommand komut = new FbCommand();

    komut.CommandText = "insert into region(region.id) values ('" + txtid.Text + "')";
    komut.ExecuteNonQuery();
    con.Close();
    Response.Write("added");
}
catch {

    Response.Write("did not add");
}

Thank you from know
Posted
v2

Don't use concatenation for queries. Rather use parameterized query to avoid SQL Injection. Read - Parameterized Queries ADO.Net[^].

Next is, handle the exception like...
C#
catch(Exception ex)

Then start debugging and see what is the exception. That would give you the details of the problem in the current code.
 
Share this answer
 
I get an error

Error:
Connection must be valid and open
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900