如何在访问数据库中搜索名称并获取有关搜索到的名称的其他信息? [英] How to search name in access DB and get other info about searched name in?

查看:96
本文介绍了如何在访问数据库中搜索名称并获取有关搜索到的名称的其他信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个需要数据库的应用。我已经使用以下信息创建了一个访问数据库。

2列:姓名和家庭
第一行
姓名:John和家人:wood

在第二行名称:sara和family:Cage

i连接数据库到C#并制作数据适配器,数据连接,数据集和数据绑定源,并将我的文件显示到数据网格视图中。到目前为止它完美无缺,我可以在我的数据库中添加更多名称但是如何搜索到Name列?如果名称不存在,则显示**名称不存在**,如果存在,则在label1中显示她/他的家人。我不知道如何提前搜索。谢谢。







I want to make an app that needs database. I already made an access database with below information.
2 columns: Name and Family
in first row Name:John and family:wood
in second row Name:sara and family:Cage
i connected database to C# and made data adapter, data connection, dataset and data binding source and showed my file into a data grid view. till now it works perfect and i can add more names into my database but how can i search into Name column? and if Name doesn't exist show **name doesn't exist** and if it exist show her/his family in label1. i have no idea about how to search.thanks in advance.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace main
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //code for search
        }
    }
}

推荐答案

此CodeProject文章< a href =http://www.codeproject.com/Articles/24043/Simple-Movie-Database-in-C-using-Microsoft-Access>使用Microsoft Access的C#中的简单电影数据库 [ ^ ]使用Access呈现一个简单的应用程序。

由于作者自己陈述
This CodeProject article Simple Movie Database in C# using Microsoft Access[^] presents a simple application using Access.
As the author himself states
Quote:

...提供的代码片段很有用,即连接到*。 mdb文件,读/写数据,使用dataGridView控件,向单元格添加按钮等

... the provided code snippets are useful, i.e. connecting to *.mdb file, read/write data, using dataGridView control, adding buttons to cells, etc.


这篇关于如何在访问数据库中搜索名称并获取有关搜索到的名称的其他信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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