954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Retrieve data from MYSQL using VB.NET

Hi ALL,

Plz tell me how to retrieve data from mysql using vb.net as frontend.
I created database in mysql and able to insert data from vb.net but i dont know how to retrieve data from mysql. Plz help me to perform this action. Plz post your reply for my question....


Regards,
Karthikeyan.

cee_karthi
Newbie Poster
5 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

cee_karthi,
Which database product are using MYSQL or MSSQL? Post code if you have. Your source must be surrounded with bb code tags.

[code=vb.net]
.. statements..
[/code]

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

cee_karthi, Which database product are using MYSQL or MSSQL? Post code if you have. Your source must be surrounded with bb code tags.

[code=vb.net] .. statements.. [/code]


Im using MYSQL. I indicated correctly in the first thread itself.

cee_karthi
Newbie Poster
5 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

Show us your code work.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

Check my blog post- http://dotnet.tekyt.info/?p=27

If you still have any doubts, feel free to ask

tuse
Junior Poster
173 posts since Jul 2007
Reputation Points: 32
Solved Threads: 14
 

Use SqlDataReader
and then ExecuteReader

Piya27
Junior Poster
112 posts since Jun 2009
Reputation Points: 22
Solved Threads: 9
 

hi cee_karthi,
if you hv been able to solved your problem..then please mark this thread as solved...

Piya27
Junior Poster
112 posts since Jun 2009
Reputation Points: 22
Solved Threads: 9
 

Hi ALL,

Plz tell me how to retrieve data from mysql using vb.net as frontend. I created database in mysql and able to insert data from vb.net but i dont know how to retrieve data from mysql. Plz help me to perform this action. Plz post your reply for my question....

Regards, Karthikeyan.


Hey cee_kathi,

Have u solved your problem in retriving data.. By the way i have my code here check it out:

Imports MySql.Data.MySqlClient
Imports System.Data
Public Class Form1
'Write your own Database code in VB .NET Tutorial using MySQL
'The Connection Object
'Dim objConn As MySqlConnection
'Dim objDataAdapter As MySqlDataAdapter
'Dim objDataset As DataSet

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
Dim objConn As MySqlConnection
Dim objDataset As New DataSet
Dim objDataAdapter As MySqlDataAdapter
Dim sqlConn As String

objConn = New MySqlConnection("server=localhost;userid=root;password=password;database=mydatabase")

objConn.Open()
sqlConn = "select * from movie"
objDataAdapter = New MySqlDataAdapter(sqlConn, objConn)
objDataAdapter.Fill(objDataset, "tblMovie")

MsgBox("The Connection is Now 'OPEN'")

objConn.Close()
MsgBox("The Connection is Now 'CLOSE'")

txtTitle.Text = objDataset.Tables("tblMovie").Rows(1).Item(1)
txtYear.Text = objDataset.Tables("tblMovie").Rows(1).Item(2)

End Sub

this is my references... http://www.homeandlearn.co.uk/NET/nets12p5.html

hope this one would help you.

By the way can you help me can you give your source code for add data in mysql database.

Thnx..

Carl

acidcool
Newbie Poster
1 post since Sep 2009
Reputation Points: 7
Solved Threads: 0
 
sqlCom = New SqlCommand("prc_InsertUniversities", sqlCon)
        sqlCom.CommandType = CommandType.StoredProcedure
        sqlCom.Parameters.Add("@Code", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Name", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Type", SqlDbType.VarChar, 30)
        sqlCom.Parameters.Add("@Address", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Email", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Web", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Location", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Period", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Certification", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Approved", SqlDbType.VarChar, 20)
        sqlCom.Parameters.Add("@Exparing", SqlDbType.VarChar, 20)

        sqlCom.Parameters("@Code").Value = TextBox1.Text
        sqlCom.Parameters("@Name").Value = TextBox2.Text
        sqlCom.Parameters("@Type").Value = TextBox16.Text
        sqlCom.Parameters("@Address").Value = TextBox3.Text
        sqlCom.Parameters("@Email").Value = TextBox4.Text
        sqlCom.Parameters("@Web").Value = TextBox5.Text
        sqlCom.Parameters("@Location").Value = TextBox6.Text
        sqlCom.Parameters("@Period").Value = TextBox7.Text
        sqlCom.Parameters("@Certification").Value = TextBox13.Text
        sqlCom.Parameters("@Approved").Value = TextBox14.Text
        sqlCom.Parameters("@Exparing").Value = TextBox15.Text

        Try
            sqlCom.ExecuteNonQuery()
            MessageBox.Show("Data Inserted Successfully", "hi", MessageBoxButtons.OK, MessageBoxIcon.Information)
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox16.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
            TextBox6.Text = ""
            TextBox7.Text = ""
            TextBox13.Text = ""
            TextBox14.Text = ""
            TextBox15.Text = ""
        Catch ex As Exception
            MessageBox.Show("Data Insertion Error", "hi", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
Kenny12
Newbie Poster
1 post since Mar 2011
Reputation Points: 8
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You