Liberty BASIC Community Forum
« Connecting My Program to MySQL Database »

Welcome Guest. Please Login or Register.
Sep 21st, 2017, 10:49am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Connecting My Program to MySQL Database  (Read 284 times)
XpL01T
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Connecting My Program to MySQL Database
« Thread started on: Aug 23rd, 2017, 5:27pm »

I need help in regards to connecting my program to a MySQL database. I'm basically wanting to create a stand alone application that is similar to a database manager where its easier for me to connect to different MySQL databases and send query's. Ive attached a screenshot and the code I currently have. Any help would be greatly appreciated. I plan on eventually adding more to the program but I need to get past this initial hump first, considering most of the functions of this program will require MySQL. Is LibertyBasic able to do this? If not, what would be a better program to use that does? Thanks in advance.


User Image



Code:

[setup.main.Window]

    '-----Begin code for #main

    nomainwin
    WindowWidth = 450
    WindowHeight = 280
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)


    '-----Begin GUI objects code

    TextboxColor$ = "white"
    textbox #main.host, 140,  82, 190,  25
    statictext #main.statictext2, "AREA 51", 160,   7, 215,  60
    statictext #main.statictext3, "Host:", 100,  87,  35,  20
    textbox #main.database, 140, 107, 190,  25
    textbox #main.username, 140, 132, 190,  25
    textbox #main.password, 140, 157, 190,  25
    statictext #main.statictext7, "Database:",  70, 112,  75,  20
    statictext #main.statictext8, "Username:",  70, 137,  75,  20
    statictext #main.statictext9, "Password:",  70, 162,  75,  20
    button #main.connect,"CONNECT",[button10Click], UL, 190, 192,  76,  25
    statictext #main.statictext11, "MySQL Database Connector", 145,  42, 171,  20

    '-----End GUI objects code

    open "Area 51 By: XpL01T" for window as #main
    print #main, "font ms_sans_serif 10"
    print #main.statictext2, "!font brutal_dude 24"
    print #main.statictext11, "!font verdana 8"

    '----Begin code for statusbar

    h=hwnd(#main)
    value$ = "Enter database info >> Connect"
    styleValue = _WS_VISIBLE or _WS_CHILD
    hStatusBar=initalizeStatusBar(h,value$)
    print #main, "resizehandler [resizeStatusbar]"

    '----End code for statusbar

    print #main, "trapclose [quit.main]"


[main.inputLoop]   'wait here for input event
    wait



[button10Click]   'Perform action for the button named 'connect'

    'Insert your own code here

    wait

[changeMessageBar]
    '----This changes the text in the statusbar
    '----Change the text in value$ then gosub this routine
    value$="Connecting..."
    a= SendMessagePtr(hStatusBar,_WM_SETTEXT,0,value$)
    wait



[resizeStatusbar]
    '----This makes the statusbar fit when window is resized
    a= SendMessageLong(hStatusBar,_WM_SIZE,0,WindowWidth)
    wait

    '----End of statusbar resizer code


[quit.main] 'End the program

    a= SendMessageLong(hStatusBar,_WM_DESTROY,0,0) 'Destroy the statusbar
    close #main
    end


'------------------------------------------------------
'----------------- Subs and Functions -----------------
'------------------------------------------------------

FUNCTION initalizeStatusBar(h, value$)

    calldll #comctl32,"InitCommonControls",_
    result as long

    styleValue = _WS_VISIBLE or _WS_CHILD
    calldll #comctl32,"CreateStatusWindow",_
    styleValue as long,_
    value$ as ptr,_
    h as long,_
    22 as long,_
    r as long
    initalizeStatusBar=r
END FUNCTION


FUNCTION SendMessagePtr(hWnd,msg,w,p$)
    CallDLL #user32, "SendMessageA",_
    hWnd As long, _
    msg As long,_
    w As long,_
    p$ As ptr,_
    SendMessagePtr As long
END FUNCTION


FUNCTION SendMessageLong(hStatusBar,msg,w,p)
    CallDLL #user32, "SendMessageA",_
    hStatusBar As long, _
    msg As long,_
    w As long,_
    p As long,_
    SendMessagePtr As long
END FUNCTION


'------------------------------------------------------
'--------------- End Subs and Functions ---------------
'------------------------------------------------------

 
« Last Edit: Aug 23rd, 2017, 7:45pm by XpL01T » User IP Logged

XpL01T
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Connecting My Program to MySQL Database
« Reply #1 on: Aug 25th, 2017, 07:27am »

Does anyone know how to do this? Please help me! I've searched and searched... Ive literally went to every page on google that has anything to do with LB & MySQL and found nothing useful. Someone out there has to know how to do this... Please share any info you may have. At this point, anything is better then nothing!
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: Connecting My Program to MySQL Database
« Reply #2 on: Aug 25th, 2017, 08:35am »

In the past a few members have used SQL Lite either directly or with a wrapper .dll

I have never seen any code working with MySQL. What precise version of MySQL are you working with?

Is there a real need for SQL based access to your data or could the project use simpler techniques? I am thinking csv or RAF style datasets.

As far as I can see ANY sql programming is complex and indeed a programming language in its own right. But you may be well versed in SQL.

I could point you at resources we have that cover SQL Lite but I don't think that is going to help much.

Tell me why you NEED sql. Multi user access? Multiple indexed datasets? End user requirement?


http://gamebin.webs.com/Liberty/SQ3_4_LB.zip
https://runbasic.wikispaces.com/No+frills+SQL+demo+database
« Last Edit: Aug 25th, 2017, 08:38am by Rod » User IP Logged

XpL01T
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Connecting My Program to MySQL Database
« Reply #3 on: Aug 25th, 2017, 4:04pm »

I run a drag racing game online plus multiple websites on different servers. I wanted to make a program that would make it easier to connect to different databases on different servers with ease. With the ability to edit table data and execute query's. I can easily login to phpmyadmin through a browser and accomplish this. But with the databases being on different servers, it is not efficient this way. I am new to programming in basic and wanted to create my first basic program that would have the ability to edit databases on the fly and something I would use daily. I think switching to a different program that is known to support MySQL is going to be my best bet. Could you explain what SQL Lite is exactly? Doing some research it looks like it may be exactly what I'm looking for. Do you have any experience with it?


I also heard something about MySQL Connector ODBC, are you familiar with that at all?

Thanks for the response.

Server version: 5.6.35 - MySQL Community Server (GPL)
Protocol version: 10
Database client version: libmysql - 5.1.73
« Last Edit: Aug 25th, 2017, 4:08pm by XpL01T » User IP Logged

Colin McMurchie
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 223
xx Re: Connecting My Program to MySQL Database
« Reply #4 on: Aug 25th, 2017, 5:45pm »

Hello XpL01T,

with reluctance, I would say that you will need to look elsewhere. Rod is right, in that the only work with LB and ODBC is well over 10 years old ( Dennis McKinley I think). People have had more success with SQLite, but I do not think that will suit your needs. SQLite is mostly a system for managing local database files using SQL techniques, rather than networked files(at least that is my impression).

There are other languages out there, including other basic dialects, that have ODBC interfaces built in, perhaps you should look there, they are easy enough to find with a goolge search.

I should say though, that you will not find anything that is as simple as LB to develop the user interface with.

Good luck, Colin McMurchie
User IP Logged

CryptoMan
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 308
xx Re: Connecting My Program to MySQL Database
« Reply #5 on: Aug 29th, 2017, 10:28pm »

This is doable with Dennis McKinney's SQL example.

Find that example.

Download MySQL ODBC driver.

Find a suitable connection string and it will work.

I did it before and I believe that I did and others posted something about MySQL before but I couldn't find it in the search.

It is identical to MS SQL.

Search for MS SQL in this forum.

Only difference is the connection string.

I think Dennis's code is awesome.
User IP Logged

.....
CryptoMan
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 308
xx Re: Connecting My Program to MySQL Database
« Reply #6 on: Aug 29th, 2017, 10:37pm »

Go to page 4 of Database Applications thread:

http://libertybasic.conforums.com/index.cgi?board=database&action=display&num=1164406137

I think SEARCH is not working properly.

I remembered correctly because I explained how to use MySQL some years ago in this forum.
User IP Logged

.....
CryptoMan
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 308
xx Re: Connecting My Program to MySQL Database
« Reply #7 on: Aug 29th, 2017, 10:41pm »

11 years ago in 2006 November.

I am getting old.
User IP Logged

.....
XpL01T
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Connecting My Program to MySQL Database
« Reply #8 on: Sep 6th, 2017, 01:55am »

Ive tried running the installer it opens command prompt and closes rather quickly. It closes so fast that I am unable to see the text on the screen. Im not sure if its the OS Im running or what. Im currently running Windows 7. Is there something Im missing? Thanks for the reply.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: Connecting My Program to MySQL Database
« Reply #9 on: Sep 6th, 2017, 03:43am »

What installer are you running?
User IP Logged

XpL01T
New Member
Image


member is offline

Avatar




PM


Posts: 5
xx Re: Connecting My Program to MySQL Database
« Reply #10 on: Sep 6th, 2017, 5:53pm »

mysql-connector-odbc-noinstall-5.2.7-winx64
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: Connecting My Program to MySQL Database
« Reply #11 on: Sep 7th, 2017, 2:07pm »

Be sure to use the MySQL forum support. If you make any progress let us know but you are in new territory for Liberty BASIC.
User IP Logged

CryptoMan
Senior Member
ImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 308
xx Re: Connecting My Program to MySQL Database
« Reply #12 on: Sep 10th, 2017, 4:51pm »

You can also use Microsoft SQLServer Express which is a FREE version.

Maybe, you will have less problems with MS SQL.

Once you install MS SQLServer Express and ODBC driver, you can use the same software by only changing the connection string.

If you want to try this, I can send you the MS SQL connection string.

SQL is SQL. Unless you already have MySQL up and running and not struggling with MySQL, I can understand but if you are looking for a good and free SQL database, MS SQLServer Express is more than enough. Learn how to use SQL with MS SQLServer and later you can try others like MySQL or PostgresSQL https://www.postgresql.org/
User IP Logged

.....
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls