Page 1 of 2

Help with VB6 code to Mobile code

Posted: Tue 20 Feb 2007 02:39
by StealthRT
Hey all I’m really new at this mobile stuff so forgive me :)

I've been coding in VB6 for a few years now and so all my programs run off a mySQL server on the internet.

This is what my connection string in VB6 looks like:

Code: Select all

Private Sub Open_Database()
Set conn = New ADODB.Connection
    With conn
        .CursorLocation = adUseClient
        .ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=xx.xxx.xx.x; DATABASE=myDB; UID=UN; PWD=PW; OPTION=3"
        .Open
    End With

    If (conn.state) Then
    Else
        MsgBox "No connection to Database, nothing will work. Please get in touch with me about this.", vbCritical, ""
        End
End Sub
Here is an example of how i gather some data.

Code: Select all

Private Sub Read_Database(intPatID As Integer)
Dim strSQL As String
Dim rst As ADODB.Recordset

    Open_Database
    Set rst = New ADODB.Recordset
    strSQL = "SELECT * FROM GuestCL WHERE ID = " & intPatID
    With rst
        .source = strSQL
        .ActiveConnection = conn
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open
    txtFirstName.Text = !FirstName & ""
    txtLastName.Text = !LastName & ""
    txtPhone.Text = !Phone & ""
    .Close
    End With
    Set rst = Nothing
End Sub
So right now I’m really not sure what I need to do in order for the mobile code to work since I haven’t seen any good examples like the ones I need (using my existing VB6 code). If anyone would be kind enough to step me though what I need to do in order to achieve the same results in the code I have in VB6 then that would be great. :)

I’ve used the Mysqlconnection1 and have made a connection to my database.

I just don’t want to drop $150 on a program I really don’t know can do what i ask it too.

I’m using Visual Studio 2005 (VB).

Thank you for your time,
David

Posted: Tue 20 Feb 2007 07:12
by Alexey
Did you see our samples in "%ProgramFiles%\CoreLab\%MySQLDirect.NET%\Samples\"? Please take a look.

Posted: Tue 20 Feb 2007 07:27
by StealthRT
Alexey wrote:Did you see our samples in "%ProgramFiles%\CoreLab\%MySQLDirect.NET%\Samples"? Please take a look.
Yes i have but i get 55 or so errors when it trys to convert it. This is the file i am opening:
C:\Program Files\CoreLab\MySQLDirect.NET2 Mobile\Samples\VB.sln

55 Errors / 20 Warnings / 0 Messages

??

David

Posted: Tue 20 Feb 2007 08:29
by Alexey
I have sent you corrected sample project (zipped and renamed to *.txt file). Do not hesitate to contact me, if you don't receive it.

Posted: Tue 20 Feb 2007 17:30
by StealthRT
I must be doing somthing wrong Alexey. I renamed the text file to Samples.sln and tryed to open it up. It tells me

"The selected file is not a valid soluction file."

I must be doing somthing wrong :(

David

Posted: Wed 21 Feb 2007 07:01
by Alexey
You should rename it to Samples.zip and then unzip it.

Posted: Wed 21 Feb 2007 07:17
by StealthRT
Thanks for the headsup there Alexey.

Doesnt seem to want to connect. I fill out all the information and after clicking on the button it takes a sec. and then goes to line:

Code: Select all

connection.Open()
Saying "Can't connect to MySQL server on 'xx.xxx.xx.x' (10061)

I know i have it correct because its the same information i use to connect to the mySQL via VB6.

and as an added note i put that same information inside the MySQLConnection and hit the "Test Connection" and it worked just fine.

David

Posted: Wed 21 Feb 2007 14:00
by Alexey
Please specify the full connection string.

Posted: Fri 23 Feb 2007 02:48
by StealthRT
I think it may not be connecting because its useing the emulator and doesnt have an internet connection for it.

Do you happen to know how i can set up the internet connection for the pocket pc 2003 SE emulator?

Thanks,
David

Posted: Fri 23 Feb 2007 09:04
by Alexey
How do you know that in doesn't have an internet connection.
Please specify the full connection string.

Posted: Sat 24 Feb 2007 03:48
by StealthRT
Ok yes, it was the internet connection. I never had one but now i got it working :)

OK, i connected to my database and ran a quary. But now how do i do what i posted in my code?

Code: Select all

Private Sub Read_Database(intPatID As Integer) 
Dim strSQL As String 
Dim rst As ADODB.Recordset 

    Open_Database 
    Set rst = New ADODB.Recordset 
    strSQL = "SELECT * FROM GuestCL WHERE ID = " & intPatID 
    With rst 
        .source = strSQL 
        .ActiveConnection = conn 
        .CursorType = adOpenDynamic 
        .LockType = adLockOptimistic 
        .Open 
    txtFirstName.Text = !FirstName & "" 
    txtLastName.Text = !LastName & "" 
    txtPhone.Text = !Phone & "" 
    .Close 
    End With 
    Set rst = Nothing 
End Sub 
Thanks,
David

Posted: Mon 26 Feb 2007 09:04
by Alexey
Please specify what exactly you need or what is the problem. Don't our samples give enough information to start programming? Did you take a look at our documentation?

Posted: Mon 26 Feb 2007 18:41
by StealthRT
Alexey wrote:Please specify what exactly you need or what is the problem. Don't our samples give enough information to start programming? Did you take a look at our documentation?
Yes i looked at all of that but it doesnt make since in the way of how i coded my program and how i retreive my information from the database.

I need an example of how to get the information and to save the information.. here is how i do it in VB6:

Code: Select all

Open_Database 
    Set rst = New ADODB.Recordset 
    strSQL = "SELECT * FROM GuestCL WHERE ID = " & intPatID 
    With rst 
        .source = strSQL 
        .ActiveConnection = conn 
        .CursorType = adOpenDynamic 
        .LockType = adLockOptimistic 
        .Open 
    txtFirstName.Text = !FirstName & "" 
    txtLastName.Text = !LastName & "" 
    txtPhone.Text = !Phone & "" 
    .Close 
    End With 
    Set rst = Nothing 
It takes the first name and places it into the txtfirstname textbox on the form. It does the same with the last name and phone number. Thats how i know how to do it in VB6 but it seems very differnet in your program.

David

Posted: Tue 27 Feb 2007 18:52
by StealthRT
Am i not explaining something right? Do you need another example of what i am looking for?

David

Posted: Thu 01 Mar 2007 09:07
by Alexey
Yes, it is different. You can't go in .NET as you do in VB6.
Look carefully at our DataReader demo project and try to spot what is going on there. This project fetches data from a database and write it into a textbox. You can use the same way to fill your textboxes.