Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET Database and Reporting > CommandText property has not been initialized


Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2012, 01:23 AM
LoliFlan LoliFlan is offline
Newcomer
 
Join Date: Jan 2012
Location: Scarlet Mansion
Posts: 13
Question CommandText property has not been initialized


Well..its been a while since my last time when I connected a DataGrid to a Database and now im getting this..

ExecuteReader: CommandText property has not been initialized

Dont really know what im missing but I dont remember this CommandText property at all so atm I have completely no idea how to solve this.

Would be happy if someone can give me a clue how to do it.

Heres my project code

Code:
Imports Un4seen.BassMOD
Imports System.Data.SqlClient

Public Class Remi

    Dim UpdatePending As Boolean = False

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            Const CS_NOCLOSE As Integer = &H200
            cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
            Return cp
        End Get
    End Property

    Private Sub Remi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AboutTab.Enabled = False
        ButtonItem3.Icon = My.Resources.main
        ButtonItem4.Image = My.Resources._exit
        'workaround for the windows 7 task manager bug, making any application maximize even without having the option set
        If Me.WindowState = FormWindowState.Maximized Then
            Me.WindowState = FormWindowState.Normal
        End If
        Try
            If Environment.OSVersion.Version > New Version(6, 1) Then
                Label1.Text = "Windows 7 Mode"
            End If
        Catch ex As Exception
            MsgBox("What did you do!?", MsgBoxStyle.Question, "um..")
            If MsgBoxResult.Ok Then
                Me.Close()
            End If
        End Try
        Try
            If Environment.OSVersion.Version < New Version(6, 1) Then
                Label1.Text = "Windows XP Mode"
            End If
        Catch ex As Exception
            MsgBox("What did you do!?", MsgBoxStyle.Question, "um..")
            If MsgBoxResult.Ok Then
                Me.Close()
            End If
        End Try
        Try
            Me.MainListTableAdapter.Fill(Me.Anime_ScarletDataSet1.MainList)
            DataGridViewX1.CellBorderStyle = DataGridViewCellBorderStyle.SingleVertical
            Me.Icon = My.Resources.main
            Me.Text = My.Resources.MainTitle
        Catch Ex As Exception
            MsgBox("The Anime Scarlet database file cannot be found!", MsgBoxStyle.Exclamation, "Heres your problem")
            If MsgBoxResult.Ok Then
                MsgBox("The application will now exit.", MsgBoxStyle.Information, "Database missing")
                If MsgBoxResult.Ok Then
                    Me.Close()
                End If
            End If
        End Try
    End Sub
    Private Sub Main_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        BassMOD.BASSMOD_Free()
        Me.MainListTableAdapter.Update(Me.Anime_ScarletDataSet1.MainList)
    End Sub

    Private Sub ButtonItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem3.Click
        Office2007StartButton1.Enabled = False
        AboutTab.Enabled = True
        AboutTab.Select()
        StatsTab.Enabled = False
        MainTab.Enabled = False
        MainTab.Tooltip = "Playing around ;3?"
        PictureBox2.Visible = True
        ButtonX1.Visible = True
        DataGridViewX1.Visible = False
        Try
            BassMOD.BASSMOD_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT)
            BassMOD.BASSMOD_MusicLoad(My.Resources.watersky, 0, 0, BASSMusic.BASS_MUSIC_RAMP + BASSMusic.BASS_MUSIC_LOOP)
            BassMOD.BASSMOD_MusicPlay()
        Catch Ex As Exception
            'currently doesnt work'
            MsgBox("Anime Scarlet cannot find BassMOD on your system!", MsgBoxStyle.Exclamation, "BASSMOD")
        End Try
    End Sub

    Private Sub ButtonX1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
        MainTab.Tooltip = "This is your main editable list, use it wisely."
        Office2007StartButton1.Enabled = True
        PictureBox2.Visible = False
        AboutTab.Enabled = False
        MainTab.Select()
        StatsTab.Enabled = True
        MainTab.Enabled = True
        ButtonX1.Visible = False
        DataGridViewX1.Visible = True
        Try
            BassMOD.BASSMOD_Free()
        Catch ex As Exception
            'currently doesnt work'
            MsgBox("Make sure bassmod.dll is in the application or your windows/system directory.", MsgBoxStyle.Exclamation, "BASSMOD")
        End Try
    End Sub

    Private Sub ButtonItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem4.Click
        Me.MainListTableAdapter.Update(Me.Anime_ScarletDataSet1.MainList)
        Me.Close()
    End Sub

    Private Sub WhatsUpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WhatsUpToolStripMenuItem.Click
        MsgBox("Are you bored or something?", MsgBoxStyle.Question, "bwa.")
        If MsgBoxResult.Ok Then
            MsgBox("Need something to do?", MsgBoxStyle.Question, "bWa?")
        End If
        If MsgBoxResult.Ok Then
            MsgBox("Well I can't help you on that.", MsgBoxStyle.Exclamation, "BWa!")
        End If
    End Sub

    Private Sub ExampleBindingSource_ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles BindingSource1.ListChanged
        If Me.Anime_ScarletDataSet1.HasChanges Then
            Me.UpdatePending = True
            Me.Validate()
        End If
    End Sub
    Private Sub DataGridView1_RowValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridViewX1.RowValidated
        If UpdatePending Then
            Me.MainListTableAdapter.Update(Me.Anime_ScarletDataSet1.MainList)
            Me.UpdatePending = False
        End If
    End Sub
    Private Sub ReFillButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.MainListTableAdapter.Fill(Me.Anime_ScarletDataSet1.MainList)
    End Sub

    Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            Me.MainListTableAdapter.FillBy(Me.Anime_ScarletDataSet1.MainList)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try

    End Sub
    Private Function AnimeListDataSet1() As Object
        Throw New NotImplementedException
    End Function
    Private Sub DataGridView1_DataError(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridViewX1.DataError

        Dim view As DataGridView = CType(sender, DataGridView)
        view.Rows(e.RowIndex).Cells(e.ColumnIndex).ErrorText = "Please delete this row and rewrite again."
        e.ThrowException = False

    End Sub

    Private Sub PictureBox2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Process.Start("http://myanimelist.net/profile/Flandre-chan")
    End Sub
End Class
Reply With Quote
  #2  
Old 08-06-2012, 11:03 AM
LoliFlan LoliFlan is offline
Newcomer
 
Join Date: Jan 2012
Location: Scarlet Mansion
Posts: 13
Default solved

I remembered what I forgot, didnt set the commands on the dataset, my bad
now its working properly.
Reply With Quote
Reply

Tags
commandtext, sqlexception


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->