Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2 Listboxes and database
#6
First, you want to add a reference to MySQL.Data to your project. Then, you want to:
[code2=vbnet]Imports MysQL.Data.MySqlClient[/code2]

Then, this is the code you're going to want to use to get the densities and boiling points from the MySQL database, or something like this:

[code2=vbnet]Dim conn As MySqlConnection = New MySqlConnection("MYSQL CONNECTION STRING")
Dim sqlQuery As String = "SELECT * FROM Chemicals WHERE Name='" & itemName & "'"
Dim command As New MySqlCommand
command.Connection = conn
command.CommandText = sqlQuery
Dim adapter As New MySqlDataAdapter
adapter.SelectCommand = command
Dim data As MySqlDataReader
conn.Open()
data = command.ExecuteReader

While data.Read
boilingPoint = CDbl(data(1))
density = CDbl(data(2))
End While

data.Close()
conn.Close()[/code2]
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
2 Listboxes and database - by qazinasir - 07-20-2012, 08:46 PM
Re: 2 Listboxes and database - by qazinasir - 07-20-2012, 09:57 PM
Re: 2 Listboxes and database - by qazinasir - 07-21-2012, 12:36 AM
Re: 2 Listboxes and database - by brandonio21_phpbb3_import2 - 07-21-2012, 12:23 PM
Re: 2 Listboxes and database - by qazinasir - 07-22-2012, 02:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VB2010 & MS Access Database kismetgerald 3 14,644 01-10-2012, 10:35 PM
Last Post: kismetgerald
  others can't connect to online database Stefanvp 3 14,502 08-14-2011, 09:46 PM
Last Post: brandonio21
  connect to online database elnashar77 3 14,669 08-09-2011, 01:27 PM
Last Post: brandonio21
  DataBase - Login - Not Working Murcs 4 17,059 07-02-2011, 09:46 AM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)