Connecting and Editng Info On sql Sever

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Connecting and Editng Info On sql Sever

Post by CaptHenry » Tue Aug 13, 2013 6:43 am

Okay so i am a nub at app development. I did the live cod university and understand the basic fundamentals of live code programing.
I am trying to develop an app that can register users to app taking their email, name, password..ext. I am having troubling connecting to the sql sever database that i have set up. I believe i understand that it need to be a global function so that users will stay logged in when move to different cards or sub stacks. I found this
"put revOpenDatabase("MySQL","127.0.0.1","my_first_database,"myLogin","myPassword") into dbID" code somewhere on the forum,
But when i input my my database host userid and password i get an error. :( I'm not able to connect to my data base.
Also if any could help me on live code to request to add new user information to data base.

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Re: Connecting and Editng Info On sql Sever

Post by CaptHenry » Tue Aug 13, 2013 4:29 pm

on mouseUp
    -- use a global variable to hold the connection ID so other scripts can use it
    global gConnectionID
    
    -- set up the connection parameters - edit these to suit your database
    put "Localhost" into tDatabaseAddress
    put "monstaen_jchat" into tDatabaseName
    put "monstaen_jchat" into tDatabaseUser
    put "......" into tDatabasePassword
    
    -- connect to the database
    put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) intotResult
    
    -- check if it worked and display an error message if it didn't
    -- & set the connection ID global
    if tResult is a number then
        put tResult into gConnectionID
        answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
    else
        put empty into gConnectionID
        answer error "Unable to connect to the database:" & cr & tResult
    end if
end mouseUp

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Re: Connecting and Editng Info On sql Sever

Post by CaptHenry » Tue Aug 13, 2013 4:33 pm

Ok so i got that code above from the live code site and put in my sql sever info but still cant get it to work i get error message "Can't connect to MySQL server on 'Localhost' (61)"

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Re: Connecting and Editng Info On sql Sever

Post by CaptHenry » Tue Aug 13, 2013 5:09 pm

So Haven't really been getting help of any one but going to keep posting as i progress i now fond what i believe is the correct host name for my sql sever srv.hosting24. com thats the company that host my site. but now i get get this error message "Access denied for user 'monstaen_Jchat'@'72.252.162.97' (using password: YES)"

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Connecting and Editng Info On sql Sever

Post by Simon » Tue Aug 13, 2013 7:55 pm

Hi CaptHenry,
Have you followed the lesson here:
http://lessons.runrev.com/s/lessons/m/4 ... l-database

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Re: Connecting and Editng Info On sql Sever

Post by CaptHenry » Tue Aug 13, 2013 8:43 pm

Yes that is the lesson i was following but when i input my sql sever info i get this error

"Access denied for user 'monstaen_Jchat'@'72.252.162.97' (using password: YES)"

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Connecting and Editng Info On sql Sever

Post by Simon » Tue Aug 13, 2013 9:35 pm

Try it using RunRev settings.
The database is actually there and running

Code: Select all

put "runrev.com" into tDatabaseAddress
    put "runrev_test" into tDatabaseName
    put "runrev_example" into tDatabaseUser
    put "example" into tDatabasePassword
Simon
EDIT: Here I forgot about this great resource:
http://www.vampire-tiger.info/livecode- ... bases.html
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Connecting and Editng Info On sql Sever

Post by Simon » Tue Aug 13, 2013 11:19 pm

OK, so I was just playing around setting up my own MySQL database and I was able to reproduce the "Access denied for user..."error.
The fix for me was to allow my host remote access.

If using cPanel it's in "Remote Database Access Hosts" for you CaptHenry it would be to allow access from 72.252.162.97.

But I do have a question, can I allow access from all hosts with just "%"?
It seems it would make remote access security redundant but then how do you determine who your users hosts are? Before they try to login?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Re: Connecting and Editng Info On sql Sever

Post by CaptHenry » Wed Aug 14, 2013 12:53 am

Thank you Simon i will try that when i get home from work... But how would i connect without changing that setting.

Also i had changed the runrev if inside that code because i wanted it to access/connect to my database so that i could start to request info and make change's to the database

put "runrev. com" into tDatabaseAddress
put "runrev_test" into tDatabaseName
put "runrev_example" into tDatabaseUser
put "example" into tDatabasePassword

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Connecting and Editng Info On sql Sever

Post by Simon » Wed Aug 14, 2013 1:14 am

The runrev code was just to test that one could actually connect to a DB. It proves that there are no other problems (firewalls and such).
But how would i connect without changing that setting
That is pretty much my question as well, the user could be on any host.

Dave Probert should be waking up now and he'll tell us or bangkok will I hope.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

CaptHenry
Posts: 7
Joined: Tue Aug 13, 2013 5:28 am

Re: Connecting and Editng Info On sql Sever

Post by CaptHenry » Wed Aug 14, 2013 2:55 am

Ok just got home..... I added my host to the remote mysql and got it to work thanks alot, i can proceed with programing.
OK, so I was just playing around setting up my own MySQL database and I was able to reproduce the "Access denied for user..."error.
The fix for me was to allow my host remote access.

If using cPanel it's in "Remote Database Access Hosts" for you CaptHenry it would be to allow access from 72.252.162.97.

But I do have a question, can I allow access from all hosts with just "%"?
It seems it would make remote access security redundant but then how do you determine who your users hosts are? Before they try to login?
But now there is that question on how will my app work on other device's if all their host will need to be added.

Hope they come on soon and help

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Connecting and Editng Info On sql Sever

Post by Simon » Wed Aug 14, 2013 9:10 pm

Giving this a bump

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dauber
Posts: 4
Joined: Wed Mar 19, 2014 4:00 pm

Re: Connecting and Editng Info On sql Sever

Post by dauber » Wed Mar 19, 2014 4:06 pm

Just started with LiveCode. Trying to connect to Sql 2005 database. Having problems.

Tried the test connect above to runrev with runrev_test, etc. Get "Can't connect to MySql server on runrev". What is that telling me?

In the long run, I am trying to use odbc to connect to Sql 2005 database.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Connecting and Editng Info On sql Sever

Post by bangkok » Wed Mar 19, 2014 5:11 pm

dauber wrote:Just started with LiveCode. Trying to connect to Sql 2005 database..
First step : create an ODBC datasource to your MS SQL server, on the PC you will use LiveCode
http://help.bluemangolearning.com/m/scr ... on-windows

2- in LiveCode, to connect to the database (where "xxx" is the name of the ODBC datasource) :

Code: Select all

put revOpenDatabase("ODBC","xxx",,"myLogin","myPassword") into tID
answer tID

dauber
Posts: 4
Joined: Wed Mar 19, 2014 4:00 pm

Re: Connecting and Editng Info On sql Sever

Post by dauber » Wed Mar 19, 2014 6:59 pm

put revOpenDatabase("ODBC","websql",,"sa","..........") into tResult
answer tResult

Created websql as System DSN on web server (DMZ) via instructions. Getting "Datasource not found and no default driver". Same message as always with the ODBC type.

Also tried connecting to SQL2008 on in network with same message.

Post Reply