请帮助.....使用带有vb.net mysql的gridview进行简单搜索 [英] Please help..... Simple search using gridview with vb.net mysql

查看:46
本文介绍了请帮助.....使用带有vb.net mysql的gridview进行简单搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用带有vb.net mysql的gridview进行简单搜索.

当我们在文本框中输入值并借助按钮提交时,如何形成查询并将记录提取到gridview.

在Advance中致谢

Simple search using gridview with vb.net mysql.

When we enter the value in the text box and submit with the help of button how can we form the query and fetch records to the gridview.

Thanks in Advance

推荐答案

请详细说明所需的输出..
Q1:SQl查询将您输入的文本作为参数传递? 问题2:如何用SQL语句的输出填充gridview?
Please elaborate the desired output you want..
Q1 : The SQl query which pass your entered text as parameter ?
Q2 : How to fill the gridview with the output of your SQL statement?




1.将gridview拖放到aspx页面/表单中.
2.将id赋予您的gridview.
3.构建一个选择查询,并使用sql适配器从后端获取数据集.
然后将其作为数据源绑定到网格视图.

这是一个示例

Hi,

1.Drag and drop a gridview in your aspx page/form.
2.Give id to your gridview.
3.Build a select query and use sql adapter to get the dataset from the backend.
Then bind it as datasource to your grid view.

Here is a example

Public Class Form1
'Declare the string variable 'connectionString' to hold the ConnectionString
Dim connectionString As String = "server=SYS2;" + "integrated security=SSPI;" +
 "database=FinAccounting"
'Declare the string variable 'str_Account_Select' to hold the SQL statement
Dim str_Account_Select As String = "SELECT * FROM AccountsTable "

Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim myAdapter As SqlDataAdapter
'Declare the DataSet object
Dim myDataSet As DataSet

Private Sub LoadData()

    'Instantiate the Connection object
    myConnection = New SqlConnection(connectionString)

    'Instantiate the Command object
    myCommand = New SqlCommand(str_Account_Select, myConnection)

    myConnection.Open()

    'Instantiate  DataSet object
    myDataSet = New DataSet()

    'Instantiate  DataAdapter object
    myAdapter = New SqlDataAdapter()

    'Set DataAdapter command properties
    myAdapter.SelectCommand = myCommand

    'Populate the Dataset
    myAdapter.Fill(myDataSet, "AccountsTable")

    If (myDataSet.Tables("AccountsTable").Rows.Count = 0) Then
       MessageBox.Show("There are currently no registries in the database.")
    Else
       DataGridView1.DataSource = myDataSet.Tables("AccountsTable")
    End If
    End Sub
End Class



相应地自定义选择查询.
希望这会有所帮助

对于连接字符串-
www.connectionstrings.com/ [ ^ ]
〜编辑〜
〜添加链接〜



Customize your select query accordingly.
Hope this helps

For Connection String-
www.connectionstrings.com/[^]
~Edit~
~Added link~


这篇关于请帮助.....使用带有vb.net mysql的gridview进行简单搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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