Page 1 of 2
Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 6:43 am
by CaptHenry
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.
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 4:29 pm
by CaptHenry
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
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 4:33 pm
by CaptHenry
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)"
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 5:09 pm
by CaptHenry
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)"
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 7:55 pm
by Simon
Hi CaptHenry,
Have you followed the lesson here:
http://lessons.runrev.com/s/lessons/m/4 ... l-database
Simon
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 8:43 pm
by CaptHenry
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)"
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 9:35 pm
by Simon
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
Re: Connecting and Editng Info On sql Sever
Posted: Tue Aug 13, 2013 11:19 pm
by Simon
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
Re: Connecting and Editng Info On sql Sever
Posted: Wed Aug 14, 2013 12:53 am
by CaptHenry
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
Re: Connecting and Editng Info On sql Sever
Posted: Wed Aug 14, 2013 1:14 am
by Simon
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
Re: Connecting and Editng Info On sql Sever
Posted: Wed Aug 14, 2013 2:55 am
by CaptHenry
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
Re: Connecting and Editng Info On sql Sever
Posted: Wed Aug 14, 2013 9:10 pm
by Simon
Giving this a bump
Simon
Re: Connecting and Editng Info On sql Sever
Posted: Wed Mar 19, 2014 4:06 pm
by dauber
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.
Re: Connecting and Editng Info On sql Sever
Posted: Wed Mar 19, 2014 5:11 pm
by bangkok
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
Re: Connecting and Editng Info On sql Sever
Posted: Wed Mar 19, 2014 6:59 pm
by dauber
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.