using the DataGridview with the ADODB connection

dualshock03

Well-known member
Joined
Jan 28, 2007
Messages
105
Programming Experience
1-3
:( ey Pros! could u guys help me fix this code??

im trying to make a search in the database using the DataGridview with the ADODB connection.
The connection does work and it can read from the database but my datagridview doesnt populate the fields..its empty! Im using MySQL database

VB.NET:
[SIZE=2]Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click


 If dupdowncatgry.Text = "Percussion Instruments" And combo1.Text = "Idiophone" Then

            Dim ds As New DataSet
            Call adodb()
            adorec.Open("SELECT * FROM percussion WHERE Idiophones = '" & txtsearch2.Text & "'", adocon, Global.ADODB.CursorTypeEnum.adOpenDynamic, Global.ADODB.LockTypeEnum.adLockOptimistic)
            If adorec.EOF = False Then
                DataGridView1.DataSource = (ds.Tables("percussion"))
                DataGridView1.DataMember = "percussion"
            Else
                MsgBox("Record Not Found")

            End If
            adorec.Close()
            adocon.Close()
        End If
[/SIZE]
Here is the Module for the ADODB declaration:

VB.NET:
#Region "Microsoft ActiveX 2.0 Lib Connection"
Module Module1

    Public adocon As New ADODB.Connection
    Public adorec As New ADODB.Recordset

    Public Sub adodb()
        adocon.ConnectionString = "DRIVER={MYSQL ODBC 3.51 DRIVER};" _
                & "SERVER=localhost;" _
                & "DATABASE=instrument;" _
                & "UID=root;PWD=pat;OPTION=3"
        adocon.Open()
    End Sub

End Module
#End Region
plss. reply as soon as possible, tnx again!
ANY COMMENTS SUGGESTIIONS, REACTIONS!! ARE VERY WELL APPRECIATED... PLS REPLY FOR ANY ALTERNATIVES OF THIS CODE THNX!!

As for my billing system topic!, for those who read that thread, i already made contract to an instructor to create that system in exchange for a billion BUCKS!! hehehe :cool:
 
Last edited:
Dont write SQLs like that.
Read the PQ link in my signature

Then, read the DW2 link in my signature - it'll tell you more about the ways of data access in .NET 2, but because youre using MySQL, the visual design stuff doesnt apply to you (because it doesnt work with MySQL)
You can still create the dataset yourself, and follow the advice for binding it.. you'll jsut have to do a lot of manual work to get the data into it.

If youre using MySQL just because it's free, dont bother - use SQLS Express or Oracle Express instead.. TBH, i think writing a MySQL DAL right now, would be biting off more than you can chew..
 
Back
Top