Visual Studio中的数据库操作 [英] Database manipulation in visual studio

查看:123
本文介绍了Visual Studio中的数据库操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

香港专业教育学院一直试图使用Visual Studio在sql Compact 3.5数据库中操作信息,但是我遇到了严重的问题.

如果谁是具有C#知识以及如何添加,删除和编辑信息的人,将非常感谢您的帮助.

语法和代码示例都将对我有所帮助
谢谢...

Good day to all.

Ive been trying to manipulate information in a sql compact 3.5 database using visual studio, but im having serious problems.

If the is anyone that has knowledge in C# and how to Add, Remove and Edit information your help would be much appreciated.

Both syntax and code examples will help me
Thanks...

推荐答案

只需使用标准的SQL命令:
Just use standard SQL commands:
DELETE FROM myTable WHERE Id=6
SELECT userName FROM myTable WHERE Id=6
UPDATE myTable SET userName='Joe' WHERE Id=6
INSERT INTO myTable (Id, userName) VALUES (7, 'Mike') (8, 'Jane')


C#代码与MsSql相同,只是您使用SqlCeConnection,SqlCeCommand等.


The C# code is just the same as for MsSql, only you use SqlCeConnection, SqlCeCommand, and so forth.

using (SqlCeConnection con = new SqlCeConnection(strConnect))
    {
    con.Open();
    using (SqlCeCommand com = new SqlCeCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
        {
        com.Parameters.AddWithValue("@C1", myValueForColumn1);
        com.Parameters.AddWithValue("@C2", myValueForColumn2);
        com.ExecuteNonQuery();
        }
    }


这篇关于Visual Studio中的数据库操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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