Help with VB6 code to Mobile code

Help with VB6 code to Mobile code

Postby StealthRT » Tue 20 Feb 2007 02:39

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Tue 20 Feb 2007 07:12

Did you see our samples in "%ProgramFiles%\CoreLab\%MySQLDirect.NET%\Samples\"? Please take a look.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby StealthRT » Tue 20 Feb 2007 07:27

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Tue 20 Feb 2007 08:29

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.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby StealthRT » Tue 20 Feb 2007 17:30

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Wed 21 Feb 2007 07:01

You should rename it to Samples.zip and then unzip it.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby StealthRT » Wed 21 Feb 2007 07:17

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Wed 21 Feb 2007 14:00

Please specify the full connection string.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby StealthRT » Fri 23 Feb 2007 02:48

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Fri 23 Feb 2007 09:04

How do you know that in doesn't have an internet connection.
Please specify the full connection string.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby StealthRT » Sat 24 Feb 2007 03:48

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Mon 26 Feb 2007 09:04

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?
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby StealthRT » Mon 26 Feb 2007 18:41

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
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby StealthRT » Tue 27 Feb 2007 18:52

Am i not explaining something right? Do you need another example of what i am looking for?

David
StealthRT
 
Posts: 12
Joined: Tue 20 Feb 2007 02:28

Postby Alexey » Thu 01 Mar 2007 09:07

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.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Next

Return to dotConnect for MySQL