如何在C#(accdb)中使用datagridview检索和存储在访问数据库中? [英] how to retrieve and store in an access databse using a datagridview In C# (accdb)?

查看:66
本文介绍了如何在C#(accdb)中使用datagridview检索和存储在访问数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在使用C#中的datagridview开发应用程序,应该从数据库(Access)检索数据并将其放在datagridview的第一列中,然后将数据存储在数据库的其他列中(用户放入其他2列)?我不知道如何使用datagridview?我已经编写并使用了很多在Internet上找到的代码,但对我没有任何帮助


帮助,提示,代码,非常感谢

Bye

Hello

I am developing an application using a datagridview in C#, I am supposed to retrieve data from the database(Access) and put in in the first column of the datagridview?, and store data in the other columns in the database (the user puts in the other 2 columns)? I dont know how to use the datagridview ? I have written and used a lot of code I have found on internet but nothing works for me


Help, tips, code, please is very appreciated

Bye

推荐答案

要从数据库中检索数据,首先我们必须与数据库建立连接...我们可以使用sqlconnection,dataadapter建立与数据库的连接,数据集,sqlcommandbuilder对象...在sqlconnection中,我们必须指定服务器名称和我们正在使用的数据库...例如,如果我们使用个人系统,则可以将服务器名称指定为localhost ...


另一种方法是拖动一个gridview ...在顶部,我们将有一个右手箭头符号..选择它...在其中选择数据源...在其中选择新的数据源..后来选择数据库..后来选择Microsoft sqlserver数据库..在其中通过浏览选择数据库...因此我们可以在网格视图中显示
To retrieve the data from database,first we have to establish the connection with the database...we can establish the connection to database by using sqlconnection,dataadapter,dataset,sqlcommandbuilder objects...in the sqlconnection we have to specify the server name and the database that we are using...for example if we are using our personal system we can specify server name as localhost...


another way is drag a gridview...in the top we will have an right hand directed arrow symbol..select it...in it choose the data source...in it select new datasource..later select database..later select microsoft sqlserver database..in it select the database by browsing...and thus we can display in grid view


这篇关于如何在C#(accdb)中使用datagridview检索和存储在访问数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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