在C#中学习Windows窗体应用程序的数据库 [英] learn database for windows form application in C#
问题描述
你好先生,
我正在尝试制作Windows窗体应用程序.但是我不知道如何在Windows窗体应用程序中进行数据库访问.
如果您有任何书籍或有用的链接,请给我.
我使用Visual Studio 2008..
hello sir,
I am try to make windows form application.but I Don''t know how to atabase access in windows form appllication.
If you have any book or any useful link for that then plz give me.
I use Visual studio 2008..
推荐答案
选中此
为初学者使用ADO.NET [ MSDN [
Check this
Using ADO.NET for beginners[^]
Also check MSDN[^] too
尝试检查以下链接:
http://www.codeguru.com/csharp/csharp/cs_network/database/article. php/c6017 [ ^ ]
通过C#访问SQL Server的入门指南 [ ^ ]
问候
robert
try to check following links:
http://www.codeguru.com/csharp/csharp/cs_network/database/article.php/c6017[^]
Beginners guide to accessing SQL Server through C#[^]
regards
robert
在Windows窗体应用程序中访问数据库就像Web一样简单
您可以通过添加
来访问它
Accesing Database in Windows Forms Application is Simple as Web
you can Access it by including
using System.Data.SqlClient;
在标题中
和
通过
创建SqlConnection类的对象
in the header
and
Create an object of SqlConnection class by
SqlConnection con=new SqlConnection("connectionstring");
这里的连接字符串就像
here connection string would be like
Data Source=SOFTWARE27\\SQLEXPRESS;Initial Catalog=AssetTrack;Integrated Security=True
您应该更改服务器名称(即DataSource),初始目录(即数据库名称);
然后要进行交易,您应该保持开放连接.
即
you should change your server name ie DataSource ,itial ctalog ie database name;
then to do transactions you should maintain an Open Connection.
ie
con.Open();
将代码写入按钮中,点击
例如插入数据
the write the code in button click
such as to insert data
SqlCommand cmd;
cmd= new SqlCommand(query, con);
cmd.ExecuteNonQuery();
认为这可能对您有帮助
快乐编程;-)
Think this Might Help You
Happy Programming;-)
这篇关于在C#中学习Windows窗体应用程序的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!