gbojsza
asked this on March 24, 2010 13:23
Can anyone help with the following error.
My database is called test
My table is called time_card
Type value: can't find object
Object Connect to db
Line dbconn_createObject "LAneon", "mysql"
Hint database key "default" was not found
Here is my script in my button "Connect to db"
on mouseUp
dbconn_createObject "LAneon", "mysql"
put the result into theError
if theError is empty then
dbconn_set "host", "192.168.0.106"
dbconn_set "username", "gbojsza"
dbconn_set "password", gbojsza
dbconn_set "database name", "test"
end if
end mouseUp
Comments
Further to my problem...
On Fedora Core 10
I have a database with a single table in it.
Database is called DataGen
Table is called sourceIP
four fields
id (autoincrement)
scrIP
Port
Size
I have three buttons with the following scripts AND NOTHING ELSE - NO Stack Script; NO Card Script
1. Button "Yoga Start" I initialize SQL Yoga here.
on mouseUp
start using stack "libSQLYoga"
sqlyoga_register "myemail address",\
"my-license-code"
end mouseUp
2. Button "Connect to db"
on mouseUp
dbconn_createObject "nrl", "mysql"
put the result into theError
if theError is empty then
dbconn_set "host", "127.0.0.1"
dbconn_set "username", "root"
dbconn_set "password", empty
dbconn_set "database name", "DataGen"
end if
end mouseUp
3. Button "Send data"
on mouseUp
dbconn_beginTransaction
put fld tData into theData
put sqlrecord_createObject("sourceIP") into theRecordA
put false into updateSQLRecordAfterInsert
repeat for each line i in theData
--put item 1 of i into theRecordA["id"] not needed since I have decided to use autoincrement
put item 2 of i into theRecordA["srcIP"]
put item 3 of i into theRecordA["Port"]
put item 4 of i into theRecordA["Size"]
sqlrecord_create theRecordA
put the result into theError
sqlrecord_set theRecordA, "id", empty
if theError is not empty then exit repeat
end repeat
if theError is empty then
dbconn_commitTransaction
else
dbconn_rollbackTransaction
end if
end mouseUp
I have a field tData that has rows of numbers that are comma separated.
I push the buttons in sequence 1, 2 and 3 and the data from the field is placed into the database which I confirm with a MYSQL tool.
So I try to do the same on Windows XP and I get error after error.
Following the SQL Yoga PDF I have also included:
dbobject_createObject
dbobject_set "storgae object", the long id of button "Database Object Storage" (created a button as outlined in doc)
dbobject_reloadSchema
So far without any success of putting data into a table?
My question is why does this work so simply on Linux - Fedora Core 10 and not work on Windows XP? I have the same rev code and MYSQL database on both systems.
This error means you probably haven't created the Database Object yet using dbobject_createObject.
You can use the SQL Yoga IDE plugin to verify that a Database object exists.
"storgae object" should be "storage object"
Is this a typo in your code or when you created this post?
Hi Trevor,
The typo was in the post.
But the main problem is still with the connect script
Type value: can't find object
Object Connect to db
Line dbconn_createObject "LAneon", "mysql"
Hint database key "default" was not found
Here is my script in my button "Connect to db"
on mouseUp
dbconn_createObject "LAneon", "mysql"
put the result into theError
if theError is empty then
dbconn_set "host", "192.168.0.106"
dbconn_set "username", "gbojsza"
dbconn_set "password", gbojsza
dbconn_set "database name", "test"
end if
end mouseUp
I do not need or use the additional commands in my Linux example and everything works.
dbobject_createObject
dbobject_set "storage object", the long id of button "Database Object Storage" (created a button as outlined in doc)
dbobject_reloadSchema
So I am trying to interpret the error database key "default" was not found.
I have started from scratch and rebooted the system, written a clean script so could it be the way I have defined and built the database and have nothing to do with Rev and SQL Yoga?
I don't want to waste anybody's time so when I figure this out I will post the solution. I know this is not a database troubleshooting forum.
regards,
Glen
`database key "default" was not found` means the Database object named "Default" was not found which means it has not been created. Calling dbobject_createObject with no parameters creates a Database object named "Default".
Did you try using the plugin to see if a Database object named "Default" exists in the Windows IDE?
OK Now we have better reference points.
On the system that is working (Linux) I discovered that the SQL Yoga was version 1.0.0 build 1.
Using this version I am able to connect to my database and send data (SQL Yoga plugin does not work with this version).
On the XP system I am using SQL Yoga was version 1.0.1 build 1. This is where my problems are occurring.
By using dbobject_createObject (confirming with Yoga plugin) I do get to connect to my database but DO NOT get to send data to it?
Back tracking to my Linux version I changed to SQL Yoga was version 1.0.1 build 1 and confirmed that I can't connect to my database unless I use dbobject_createObject. Once I do connect I get the same error that I am now getting on the XP system which is:
value: can't find object
Object Send data
Line put sqlrecord_createObject("sourceIP") into theRecordA
Hint table 'sourceIP' is not in the schema 'default'
So between the two versions of SQL Yoga, the earlier version seems to work without doing additional steps.
So my question is what do I need to resolve this error with the table 'sourceIP' is not in the schema 'default'?
I tried the XP with SQL Yoga was version 1.0.0 build 1 and it works fine. So whatever has been changed between versions requires the latest version to have additional commands to be done.
Additional error checking was added inbetween versions so that certain operations wouldn't succeed unless you created a database object first. If the table is not in the schema then you should be able to call dbobject_reloadSchema (making sure that a valid connection exists first as SQL Yoga needs to talk to your db).
You can reload the schema using the plugin as well using these instructions.
Could these have not been kept in SQL Yoga? I don't mind adding them to my stack but it was nice to have it all handled by SQL Yoga.
Also, up to now I have been just inserting numbers into the database but now I have added a text field and when trying to add this to the database I get the following error.
errorDialog "sqlyoga_executedsql_err,0,0,Unknown column 'Bob' in 'field list'
(INSERT INTO timecard
(Regular_Time,First__Name,Over_Time,LAStamp,Code,Employee_Number,Date,Project)
VALUES(8,23,211111,234,987,Bob,2010-03-24,1234))
.
.
.
The Date also seems to convert to 1983?
My script is as follows:
on mouseUp
dbconn_beginTransaction
put fld tData into theData
put sqlrecord_createObject("timecard") into theRecordA
put false into updateSQLRecordAfterInsert
set itemdel to comma
repeat for each line i in theData
put item 1 of i into theRecordA["LAStamp"]
put item 2 of i into theRecordA["First_Name"]
put item 3 of i into theRecordA["Employee_Number"]
put item 4 of i into theRecordA["Date"]
put item 5 of i into theRecordA["Project"]
put item 6 of i into theRecordA["Code"]
put item 7 of i into theRecordA["Regular_Time"]
put item 8 of i into theRecordA["Over_Time"]
sqlrecord_create theRecordA
put the result into theError
sqlrecord_set theRecordA, "id", empty
if theError is not empty then exit repeat
end repeat
if theError is empty then
dbconn_commitTransaction
else
dbconn_rollbackTransaction
end if
end mouseUp
The schema will be stored in your SQL Yoga database object. The first time SQL Yoga connects to a db it will read the schema in. If you make changes to the schema then you have to tell SQL Yoga to update the schema. Now that you have updated the schema in SQL Yoga you should not have to do it again (assuming you saved the Database object) unless you change your db schema.
Regarding the error - when working with Record objects you should be using sqlrecord_set. See the example in the documentation: http://revolution.screenstepslive.com/spaces/revolution/manuals/sqlyoga/lessons/5866-Create-Records-in-the-Database-Using-SQL-Record-Objects.
SQL Yoga stores information about which fields should be escaped within the array theRecordA itself. Using sqlrecord_set updates these internal values as necessary.
It is helpful to think of the array that is created with sqlrecord_createObject as an object that requires you to use a getter and a setter. Since revCode has no concept of faceless objects I have to use arrays to implement this.
If you just want to work with arrays you can use a SQL Query object instead. SQL Query objects don't provide fancy things like callbacks and the like but if you don't need those features then they can be faster. See the following example:
http://revolution.screenstepslive.com/spaces/revolution/manuals/sqlyoga/lessons/11270-How-Do-I-Create-Records-In-a-Database-Table-Using-a-SQL-Query-Object-
The first link returns "Page not found"
Oops, included the trailing "." in the url. Fixed now.