Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6596673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:06:23+00:00 2026-05-25T18:06:23+00:00

I have the following controls: textbox1 – this is where i type a message.

  • 0

I have the following controls:

  • textbox1 – this is where i type a message.
  • listbox1 – this is where i display the messages.
  • button1 – this is what posts my messages to the server.
  • StatusStrip1.Title1 – this is where the current user’s title will go. (i.e: Administrator, manager… etc.)

I have a table on a MYSQL database called “messages” and a column called “message”. When i type something into textbox1 and click button1 i want to add a row to “messages” under the column “message” with the title and message as its value.(separated by a hyphen, dash, or other small delimiter)Then reload listbox1’s contents to show the new message.

so i want the final message to be something like:

Administrator – Hello World!

I currently have the following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim sqlpost As MySqlCommand = New MySqlCommand("INSERT INTO messages(message) VALUES(?name - ?message)"";", con)
    sqlpost.Parameters.AddWithValue("?name", Title2.Text)
    sqlpost.Parameters.AddWithValue("?message", TextBox1.Text)
    Try
        con.Close()
        con.Open()

        ' Sending message.
        If TextBox1.Text = "" Then
            MessageBox.Show("You forgot to type a message!")
        Else
            sqlpost.ExecuteNonQuery()

            ' Reloading messages.

            ListBox1.Items.Clear()
            reader = sqlmessages.ExecuteReader()
            While (reader.Read)
                ListBox1.Items.Add(reader.Item("message"))
                ListBox1.Items.Add("")

            End While
            reader.Close()
            con.Close()
            TextBox1.Text = ""
            Label4.Text = "Message Sent!"
            Timer2.Start()
        End If

    Catch myerror As MySqlException
        MessageBox.Show("Error sending message to server: " & myerror.Message)
    End Try

End Sub

I had it working before, but when i made changes to it, it came up with various sql statement syntax errors… (stuff like invalid truncated value of “Administrator”, or invalid DOUBLE value “hello”) and now it won’t even display any messages currently in the “messages” table…)

If anyone could tell me what i’m doing wrong, or a more efficient way of doing this then i would greatly appreciate it! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:06:24+00:00Added an answer on May 25, 2026 at 6:06 pm

    One thing I see that looks incorrect is that you are using “?” for you parameter names in the query. The default character to use for parameter names is to start them with “@”. Although I think there’s a connection string option to use “?” as that is what was used in the older versions of the MySQL connector, but the current default is “@”. Also, there seems to be some problems with your command in general. You have:

    Dim sqlpost As MySqlCommand = New MySqlCommand("INSERT INTO messages(message) VALUES(?name - ?message)"";", con)
    

    it should probably be something more like

    Dim sqlpost As MySqlCommand = New MySqlCommand("INSERT INTO messages(message) VALUES(@message);", con)
    

    I fixed up the query a bit, and replaced the ? with @. You you can do the concatenation of name and message (as you cleared up in the comment) in VB, with some code such as this:

    sqlpost.Parameters.AddWithValue("@message", Title2.Text & " - " & Title2.Text)
    

    I also see that you are calling

    sqlmessages.ExecuteReader()
    

    but I don’t see where this is being initialized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: foreach (var control in this.Controls) { } I want
I have the following html: <html> <body> <form runat=server> Name: <input type=text name=name />
I have the following control: <asp:TextBox ID=textbox1 runat=server Width=95px MaxLength=6 /> which i would
I have the following textbox server control in my web page: <asp:TextBox ID=txtZip runat=server
I have the following code that controls the presentation of an interdependent group. The
I have the following XAML: <UserControl x:Class=EMS.Controls.Dictionary.TOCControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:vm=clr-namespace:EMS.Controls.Dictionary.Models xmlns:diagnostics=clr-namespace:System.Diagnostics;assembly=WindowsBase x:Name=root > <TreeView
I have the following code: <video width=640 height=360 controls id=video-player poster=/movies/poster.png> <source src=/movies/640x360.m4v type='video/mp4;
How would I setup my controls for the following situation?: I have a parent-container
I have the following set of controls. Scenario 1: If you select one of
I have the following code in my DataGridTemplateColumn: <Controls:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <StackPanel Orientation=Horizontal> <TextBox Text={Binding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.