on mouseUp
-- connect to the database
put revOpenDatabase("ODBC", "TESTDSN",, "testuser", "password") into tResult
-- check for connection.
if tResult is a number then
put "Connected to the database." & cr & "Connection ID = " & tResult into Field "outputField"
else
put "Connection failed." into Field "outputField"
end if
put revDataFromQuery (tab,cr,tResult, "select distinct patient_id, patient_name, study_date from T_DATA") into tData
revCloseDatabase tResult
end mouseUp
tResult does indeed return a number; however, when the app gets to my query, LiveCode hangs until I have to quit.
thoughts?
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
bangkok wrote:I use LiveCode (and before RunRev 3.5, 4) to query a MS SQL 2008 server, without any glitch since more than 1 year.
Since your SQL query gives you an error with SQL Management Studio, why don't you try something more simple ?
Like :
select patient_id from T_DATA
I gave that a go and that did work.. I did some more testing and found that nvarchar columns will query fine; however, if I attempt to query datetime then LiveCode freezes.
do I have to handle datetime fields differently when I query from LiveCode?
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
put revDataFromQuery(tab,cr, gConnectionID, "select distinct convert(char,study_date,110) as date from T_DATA ") into tData
Its odd though, because by default MS SQL is displaying study_date as YYYY-MM-D HH:MM:SS in which you would think could be queried without the convert statement.
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
I presumed that you store dates in LiveCode in another format than the database does.
If you DON'T do this, then there is no need to convert unless you need ot add the time 00:00:00.
But maybe I just misunderstand something?
in the convert statement I used in my previous post, I was playing around with just converting datetime to a char. Since its a char, then it doesnt really matter what the string looks like since its a string.
if I run the same select statement in LiveCode it freezes which leads me to believe that LiveCode is not able to process a select statement with a datetime column.
do I need HH:MM:SS no, I was simply just trying to understand why LiveCode was not able to query datetime without the need for convert
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4