Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 20:03pm
Edited 21-Sep-12 11:25am
(no name)110.1K
v2
Comments
Kenneth Haugland at 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 at 21-Sep-12 17:29pm
   
Any errors? Does your query return any results?
Ervin Pacibe at 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 at 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
0 OriginalGriff 420
1 CHill60 410
2 Sergey Alexandrovich Kryukov 354
3 BillWoodruff 190
4 PIEBALDconsult 160


Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2014
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