插入数据库时​​丢失数据 [英] Missing datas when inserting to database

查看:111
本文介绍了插入数据库时​​丢失数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,


我有Web应用程序,需要将数据插入数据库.

我正在使用mssql数据库.
和我的查询如下;

Dear all,


I have web application and need to insert data to database.

I am using mssql database.
and my query like below;

sqlcommand cmd=new sqlcommand("insert into tbnm values(''"+txtNm.text+"'',etc..);



但是有时缺少值时会插入.这并非总是如此,但有时.

请帮帮我.

并告诉您哪种是插入数据库的最佳方法


致谢,
Kalesh:confused:



but some times when inserting values missing .This is not always but some times.

please help me.

and please tell which is the best method to insert into database


Regards andThanks,
Kalesh:confused:

推荐答案

您应该使用参数化查询来执行任何数据库操作,这将帮助您避免任何SQL注入问题,并且代码将更具可读性.

检查此链接参数化查询 [
You should use Parameterized Queries to perform any database operatiosn, it will help you to avoid any SQL Injection problems, and your code will be more readable.

Check this link Parameterized Queries[^]


这篇关于插入数据库时​​丢失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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