Populate ListView With Mysql Table
I am new to using MySql but working on a new project that uses it.
I have searched and searched but have not found code that worked for me. I need to get the data from a mysql db to my listview. I can already connect to the db, i just need the code to get the stuff from it to the listview.
thanks!
Re: Populate ListView With Mysql Table
Hey,
Take a look at the VB and MySql link in my signature. It is a very good series of articles, that deal with using MySql in VB.Net.
As a brief note though, there is really no difference between using MySql and SQL, assuming you are using the connector for .net. So if you can so this using SQL Server, or have an example for SQL Server, it should be a direct swap to use MySql.
Gary
Re: Populate ListView With Mysql Table
ok can someone help me with this. I am trying to update the table programs. I don't know what to put in the values line
Code:
Dim conn As MySqlConnection
Dim myCommand As New MySqlCommand
'connect to DB
conn = New MySqlConnection()
conn.ConnectionString = ";"
'Dim myCommand As New MySqlCommand
myCommand.Connection = conn
myCommand.CommandText = "INSERT INTO programs(name, type, uploaded, uploader, location)" _
& "'VALUES(?Name, ?Type, ?Uploaded, ?Uploader, ?location)'"
myCommand.Parameters.AddWithValue("?Name", Me.TextBox1.Text)
myCommand.Parameters.AddWithValue("?Type", Me.TextBox2.Text)
myCommand.Parameters.AddWithValue("?Uploaded", Me.TextBox3.Text)
myCommand.Parameters.AddWithValue("?Uploader", Me.TextBox4.Text)
myCommand.Parameters.AddWithValue("?location", www.site.com/files/'" & Me.TextBox4.Text & "'/'" & FileName)
Try
conn.Open()
myCommand.ExecuteNonQuery()
Catch myerror As MySqlException
MsgBox("There was an error updating the database: " & myerror.Message)
End Try
Re: Populate ListView With Mysql Table
Hey,
What is wrong with what you have?
You are going to need to provide more information as to what the problem is, before anyone is going to be able to help you.
Gary
Re: Populate ListView With Mysql Table
well i don't know mysql at all so really dont know what to do.
my database has 5 columns...
name
type
uploaded
uploader
location
I need textbox1 to go under name
textbox2 to go under type
textbox3 to go under uploaded
textbox4 to go under uploader
and www.site.com/files/ & filename to go under location
I just dont know the correct sql statemnt
Re: Populate ListView With Mysql Table
Hey,
I would suggest that you download yourself a copy of SqlYog, you can find a link to it in my signature. This will help you construct the queries that you need to make against your database.
There are some noticeable differences between the syntax for SQL and MySQL, but or a simple insert query, there shouldn't be that much difference.
I would also suggest that you have a look at the documentation for the connector:
http://dev.mysql.com/doc/refman/5.0/...ector-net.html
specifically:
http://dev.mysql.com/doc/refman/5.0/...-prepared.html
If you are still having trouble after reading over that, post some more specific questions.
Gary