| | |
Error connecting to MySql
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 7
Reputation:
Solved Threads: 0
hello everyone, i need to make a program that will show/load the images stored in mysql database, i've already created the database and my problem is i can't load it in my vb code....
here's my code below
Dim conn As MySqlConnection
'connect to database
conn = New MySqlConnection()
conn.ConnectionString = "server = localhost; id = root; password = mypass; database=face manager"
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error connecting to database")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM eyes"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
thanks, i need any response
here's my code below
Dim conn As MySqlConnection
'connect to database
conn = New MySqlConnection()
conn.ConnectionString = "server = localhost; id = root; password = mypass; database=face manager"
Try
conn.Open()
Catch myerror As MySqlException
MsgBox("Error connecting to database")
End Try
'sql query
Dim myAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM eyes"
Dim myCommand As New MySqlCommand()
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader()
thanks, i need any response
For some reason I didn't get DataReader to work. But with DataAdapter and DataSet I got images from DB. I used SQL Server but that shouldn't make any difference.
You also have to import System.IO namespace to use memory stream.
VB.NET Syntax (Toggle Plain Text)
'start query ' Declare a DataSet object Dim Images As New DataSet() myAdapter.Fill(Images, "Eyes") ' With DataAdapter you can close connection, with DataReader you have to keep connection open and close it at the end conn.Close() ' Buffer to hold image data Dim ByteArr() As Byte Dim ImageIndex As Integer Dim i As Integer ImageIndex = 0 ' Column index of images, set the right value in here ' Loop all rows For i = 0 To Images.Tables(0).Rows.Count - 1 ' Read a BLOB to buffer ByteArr = CType(Images.Tables(0).Rows.Item(i).Item(ImageIndex), Byte()) ' Create a memory stream of the buffer Dim ImageStream As New MemoryStream(ByteArr) ' Get the image from the memory stream PictureBox1.Image = Image.FromStream(ImageStream) ' "Refresh" display Application.DoEvents() ' Wait 3 seconds System.Threading.Thread.Sleep(3000) Next i
Teme64 @ Windows Developer Blog
Hi!
Just verify these-
Do you have the MySQL Connector installed?
Are you sure your connection string is correct?
Just verify these-
Do you have the MySQL Connector installed?
Are you sure your connection string is correct?
My blog on .NET- http://dotnet.tekyt.info
try this connection string-
VB.NET Syntax (Toggle Plain Text)
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
My blog on .NET- http://dotnet.tekyt.info
![]() |
Similar Threads
- [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server 10060 (Visual Basic 4 / 5 / 6)
- error in connecting MySql and PHPBB help me..... (MySQL)
- Problems connecting to MySQL (IT Professionals' Lounge)
- Problems using a php generator (PHP)
- hit another brick wall, mysql :S (PHP)
- php mysql help (PHP)
- Connecting to MySQL (MySQL)
Other Threads in the VB.NET Forum
- Previous Thread: Teach Me a Comeback to Visual Basic.net Programming
- Next Thread: Is it worth getting Visual Basic Professional Edition?
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel file-dialog firewall folder ftp google hardcopy image images insert listview login math memory mobile ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print problemwithinstallation project reports" save savedialog searchbox serial server soap sql string table tcp temp text textbox timer toolbox trim update updown upload useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





