Click here to Skip to main content
12,634,101 members (26,639 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Here is my Code...
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 20-Sep-12 21:03pm
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?
Wes Aday 21-Sep-12 17:29pm
   
Any errors? Does your query return any results?
Ervin Pacibe 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.
Ervin Pacibe 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100