在网站中插入数据列表视图 [英] insert data listview in website

查看:88
本文介绍了在网站中插入数据列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做项目。我想在listview中列出,但我不这样做。



我该怎么办?

I am doing project. I want to list in listview but I dont do.

How can I do?

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

推荐答案

转到此链接。



http://www.aspsnippets.com/Articles/Display-Show-data-in-ListView-from-database-in-ASPNet-using-C-and-VBNet.aspx [ ^ ]


不要使用连接进行查询。而是使用参数化查询来避免SQL注入。阅读 - 参数化查询ADO.Net [ ^ ]。



接下来是,处理异常,例如......

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...
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.


我收到错误



错误:

连接必须有效且打开
I get an error

Error:
Connection must be valid and open


这篇关于在网站中插入数据列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆