在数据网格视图中显示记录,以选择组合框值。 [英] Display Records in Data Grid view against selection of combo box vale.
本文介绍了在数据网格视图中显示记录,以选择组合框值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从Sql&获取记录显示它在数据网格视图中选择组合框值。我正在使用Vb.net& Sql Server '05。
我正在使用以下代码:
I am trying to Fetch record from Sql & display it in Data Grid View against the selection of Combo Box value.I am using Vb.net & Sql Server ''05.
I am using Following code:
Public Function GetView(ByVal strQuery As String) As DataSet
Dim ds As New DataSet
Dim da As New SqlDataAdapter(strQuery, SetCon())
da.Fill(ds, "New")
Return ds
End Function
Dim dsvalue As DataSet
dsvalue = obj.GetView("Select p.PO_no,p.Date,s.Name from PO_Header p, SupplierMaster s Where p.Sup_no = " & cmbSupplierName.SelectedValue & ";" )
DataGridView1.DataSource = dsvalue.Tables(0).DefaultView
系统显示错误:没有为字符串选择p.PO_no定义操作符''&'', p.Date,s.Sup_name和type''DataRowView''。
System show me Error :Operator ''&'' is not defined for string "Select p.PO_no,p.Date,s.Sup_name" and type ''DataRowView''.
推荐答案
Dim connectionstring As String =Driver = MySQL ODBC 3.51 Driver; Server = localhost; port = 3306; uid = root; pwd = admin; Database = dbname;
Dim conn As New OdbcConnection(connectionstring)
conn.Open()
Dim da As New OdbcDataAdapter(select * from Userpass where Username like''%&ComboBox1.Text&%'',conn)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
conn.Close()
Dim connectionstring As String = "Driver=MySQL ODBC 3.51 Driver;Server=localhost;port=3306;uid=root;pwd=admin;Database=dbname;"
Dim conn As New OdbcConnection(connectionstring)
conn.Open()
Dim da As New OdbcDataAdapter("select * from Userpass where Username like ''%" & ComboBox1.Text & "%''", conn)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
conn.Close()
GetView似乎是一种自定义方法。尝试调试方法以找出该方法的预期结果。
GetView appears to be a custom method. Try debugging the method to find out what exactly is expected by that method.
我试过了。
根据你的建议我调试代码仍然无法理解为什么系统显示错误。
请帮帮我。
I tried out.
As per your suggestion I debug the code still not able to understand why system shows that error.
Please help me.
这篇关于在数据网格视图中显示记录,以选择组合框值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文