Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. vb.net mysql javascript

vb.net mysql javascript

Scheduled Pinned Locked Moved Visual Basic
databasecsharpjavascripthtml
3 Posts 3 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AMRO DAMMAM
    wrote on last edited by
    #1

    Public Sub FetchDataByName(customerName As String)
    ' Show debugging message
    MessageBox.Show("FetchDataByName called with Name: " & customerName)

        ' Replace with your actual MySQL connection details
        Dim connectionString As String = "Server=localhost;Port=3306;Database=MyData;Uid=asmgssl;Pwd=0786;"
        Dim query As String = "SELECT \* FROM customer WHERE cname = @cname"
    
        Try
            Using connection As New MySqlConnection(connectionString)
                connection.Open()
                Using command As New MySqlCommand(query, connection)
                    command.Parameters.AddWithValue("@cname", customerName)
                    Using reader As MySqlDataReader = command.ExecuteReader()
                        ' Process query result
                        If reader.Read() Then
                            ' Example: Retrieve data and show in message box
                            Dim customerId As Integer = reader.GetInt32("id")
                            Dim customerAddress As String = reader.GetString("address")
                            MessageBox.Show($"Customer ID: {customerId}, Address: {customerAddress}")
                        Else
                            MessageBox.Show("No data found for Name: " & customerName)
                        End If
                    End Using
                End Using
            End Using
        Catch ex As Exception
            MessageBox.Show("Error fetching data: " & ex.Message)
        End Try
    End Sub
    
    Private Sub LoadHtmlContent()
        ' Define the HTML content
        Dim html As String = "" &
                         "" &
                         "" &
                         "Test Page" &
                         "" &
                         "function FetchDataByName() {" &
                         "    if (window.external && typeof window.external.FetchDataByName === 'function') {" &
                         "        var customerName = document.getElementById('inputName').value;" &
                         "        console.log('Fetching data for customer name: ' + customerName);" &
                         "        window.external.FetchDataByName(customerName);" &
                         "    } else {" &
                         "        console.error('window.external.FetchDataByName is not available.');" &
                         "    }" &
                         "}" &
    

    </x-turndown>

    V D 2 Replies Last reply
    0
    • A AMRO DAMMAM

      Public Sub FetchDataByName(customerName As String)
      ' Show debugging message
      MessageBox.Show("FetchDataByName called with Name: " & customerName)

          ' Replace with your actual MySQL connection details
          Dim connectionString As String = "Server=localhost;Port=3306;Database=MyData;Uid=asmgssl;Pwd=0786;"
          Dim query As String = "SELECT \* FROM customer WHERE cname = @cname"
      
          Try
              Using connection As New MySqlConnection(connectionString)
                  connection.Open()
                  Using command As New MySqlCommand(query, connection)
                      command.Parameters.AddWithValue("@cname", customerName)
                      Using reader As MySqlDataReader = command.ExecuteReader()
                          ' Process query result
                          If reader.Read() Then
                              ' Example: Retrieve data and show in message box
                              Dim customerId As Integer = reader.GetInt32("id")
                              Dim customerAddress As String = reader.GetString("address")
                              MessageBox.Show($"Customer ID: {customerId}, Address: {customerAddress}")
                          Else
                              MessageBox.Show("No data found for Name: " & customerName)
                          End If
                      End Using
                  End Using
              End Using
          Catch ex As Exception
              MessageBox.Show("Error fetching data: " & ex.Message)
          End Try
      End Sub
      
      Private Sub LoadHtmlContent()
          ' Define the HTML content
          Dim html As String = "" &
                           "" &
                           "" &
                           "Test Page" &
                           "" &
                           "function FetchDataByName() {" &
                           "    if (window.external && typeof window.external.FetchDataByName === 'function') {" &
                           "        var customerName = document.getElementById('inputName').value;" &
                           "        console.log('Fetching data for customer name: ' + customerName);" &
                           "        window.external.FetchDataByName(customerName);" &
                           "    } else {" &
                           "        console.error('window.external.FetchDataByName is not available.');" &
                           "    }" &
                           "}" &
      

      </x-turndown>

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      AMRO DAMMAM wrote:

      not fetch data

      Did you debug your code?

      1 Reply Last reply
      0
      • A AMRO DAMMAM

        Public Sub FetchDataByName(customerName As String)
        ' Show debugging message
        MessageBox.Show("FetchDataByName called with Name: " & customerName)

            ' Replace with your actual MySQL connection details
            Dim connectionString As String = "Server=localhost;Port=3306;Database=MyData;Uid=asmgssl;Pwd=0786;"
            Dim query As String = "SELECT \* FROM customer WHERE cname = @cname"
        
            Try
                Using connection As New MySqlConnection(connectionString)
                    connection.Open()
                    Using command As New MySqlCommand(query, connection)
                        command.Parameters.AddWithValue("@cname", customerName)
                        Using reader As MySqlDataReader = command.ExecuteReader()
                            ' Process query result
                            If reader.Read() Then
                                ' Example: Retrieve data and show in message box
                                Dim customerId As Integer = reader.GetInt32("id")
                                Dim customerAddress As String = reader.GetString("address")
                                MessageBox.Show($"Customer ID: {customerId}, Address: {customerAddress}")
                            Else
                                MessageBox.Show("No data found for Name: " & customerName)
                            End If
                        End Using
                    End Using
                End Using
            Catch ex As Exception
                MessageBox.Show("Error fetching data: " & ex.Message)
            End Try
        End Sub
        
        Private Sub LoadHtmlContent()
            ' Define the HTML content
            Dim html As String = "" &
                             "" &
                             "" &
                             "Test Page" &
                             "" &
                             "function FetchDataByName() {" &
                             "    if (window.external && typeof window.external.FetchDataByName === 'function') {" &
                             "        var customerName = document.getElementById('inputName').value;" &
                             "        console.log('Fetching data for customer name: ' + customerName);" &
                             "        window.external.FetchDataByName(customerName);" &
                             "    } else {" &
                             "        console.error('window.external.FetchDataByName is not available.');" &
                             "    }" &
                             "}" &
        

        </x-turndown>

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You have not given sufficient information to diagnose this. "no fetch data" can mean anything at any point in this code. You have a bunch of MessageBox statements which should be showing you the important values, but you don't mention anything at all about what they are saying.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups