Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Here is my Code...
VB
Dim _data As New DataGridView
        Dim MyDataTable As New DataTable
        Dim strQuery As String = Application.StartupPath & "\strquery.txt"

        If System.IO.File.Exists(strQuery) = True Then
            Dim objReader As New System.IO.StreamReader(strQuery)
            strQuery = objReader.ReadToEnd
        Else
            MsgBox("OR Sql Query file does not exists!", MsgBoxStyle.Information, "Security Information")
            Exit Sub
        End If
        Dim MySqlCommand As SqlCommand = New SqlCommand(strQuery)
        Call conn()

        MySqlCommand.CommandType = CommandType.Text
        MySqlCommand.Connection = MySqlConnection

        Dim MySqlDataAdapter As SqlDataAdapter = New SqlDataAdapter
        MySqlDataAdapter.SelectCommand = MySqlCommand

        Try
            MySqlConnection.Open()
            MySqlDataAdapter.SelectCommand = MySqlCommand
            MySqlDataAdapter.Fill(MyDataTable)
            _data.DataSource = MyDataTable


        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            MySqlConnection.Close()
            MySqlConnection.Dispose()
            MySqlDataAdapter.Dispose()
        End Try

When I checked the rowcount of _data the value is 0.

Please help me.
Posted
v2
Comments
Kenneth Haugland 21-Sep-12 17:29pm    
Are the MyDataTable filled with objects? And Id like to see you query string as well... And whats hidden in conn?
[no name] 21-Sep-12 17:29pm    
Any errors? Does your query return any results?
xErvender 23-Sep-12 23:22pm    
i dont have error.. the query is correct because i have a datagridview in the form to make sure the query is correct..but i dont need the datagridview in form.. i need to pass the data of MyDataTable in _Data.
xErvender 23-Sep-12 23:27pm    
@kenneth Huagland the sub conn is the sql connection..

btw thx for reply guys

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900