如何编辑Sql Ce Edition数据库? [英] How Do I Edit Sql Ce Edition Database?
本文介绍了如何编辑Sql Ce Edition数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个紧凑版的sql server连接
它完美运行...
但我无法手动编辑表格
string item = itemName.Text;
int 数量= Convert.ToInt32(itemQty.Text);
string connectionString = 数据源= C:\\Users \\Jeewani \\Documents\\rundown.sdf;;
SqlCeConnection sql = new SqlCeConnection(connectionString);
sql.Open();
string query = INSERT INTO ItemsNames(ItemName,ItemQty)VALUES(' + item + ',' + Qty + ');
SqlCeCommand myCommand = new SqlCeCommand(query,sql);
myCommand.ExecuteNonQuery();
// myinfo.Text =与db建立连接;
sql.Close();
谢谢
解决方案
< blockquote>试试这个项目: https://sqlcedatabaseeditor.codeplex.com/ [ ^ ]
我想我遇到了这个问题...
A数量
变量是整数数据类型:
int Qty = Convert.ToInt32(itemQty.Text);
所以,你需要更换这个:
string query = INSERT INTO ItemsNames(ItemName,ItemQty)VALUES(' + item + ',' +数量+ ');
这个:
string query = INSERT INTO ItemsNames(ItemName,ItemQty)VALUES(' + item + < span class =code-string> ', + Qty + < span class =code-string>);
有什么区别?我在数量
附近删除了''
。
注意:您的代码是 sql注入 [ ^ ]可用。解决方案:使用参数化查询 [ ^ ]。
i have created a compact edition sql server connection
it works perfectly...
but i cant edit table manually
string item = itemName.Text;
int Qty = Convert.ToInt32(itemQty.Text);
string connectionString = "Data Source=C:\\Users\\Jeewani\\Documents\\rundown.sdf;";
SqlCeConnection sql = new SqlCeConnection(connectionString);
sql.Open();
string query = "INSERT INTO ItemsNames(ItemName,ItemQty) VALUES('" + item + "', '" + Qty + "')";
SqlCeCommand myCommand = new SqlCeCommand(query, sql);
myCommand.ExecuteNonQuery();
// myinfo.Text = "connection to db is made";
sql.Close();
thank you
解决方案
Try this project : https://sqlcedatabaseeditor.codeplex.com/[^]
I think i got the issue...
AQty
variable is integer data type:
int Qty = Convert.ToInt32(itemQty.Text);
So, you need to replace this:
string query = "INSERT INTO ItemsNames(ItemName,ItemQty) VALUES('" + item + "', '" + Qty + "')";
with this:
string query = "INSERT INTO ItemsNames(ItemName,ItemQty) VALUES('" + item + "', " + Qty + ")";
What's the difference? I removed''
aroundQty
.
Note: your code is sql injection[^] volnurable. Solution: Use parametrized queries[^].
这篇关于如何编辑Sql Ce Edition数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文