PDA

View Full Version : QSqlQuery Fails when calling stored procedures taking QString>127 chars- -HELP!!!



nish
28th June 2007, 08:04
hi there!!


I am having problems on porting a sql app from qt3 to qt4.
I must tell u that i dont know SQL and i have not used QSql before.. i was porting an application to qt 4 so i got some knowlegde of SQL and qt's SQL module.

the application connects to a MS SQL server 7.0 database on network (QODBC).
i call QSqlDataBase::addDatabase("QODBC", "myID"); and all other initializing functions and the
database is connnected succesfully.
now i can execute simple SQL queries without any problem.

The problem is on calling the stored procedure on the database.

i made a small, very simple stored procedure whose code is ->


CREATE proc GetTransactionTest
@pin_type nvarchar(20),
@pou_year numeric(4) output,
@pou_text nvarchar(2000) output
as

begin

----- Initialize out parameters ----
select @pou_trans_year=2007
select @pou_trans_text="Some long text from record"
------------------------------------
end

this procedure takes one input "pin_type" and two output parameters viz "pou_year",
"pou_text".

now i have the sqlquery code in my app like this ->



void MyClass::callDBprocedure() {
QSqlQuery *query=new QSqlQuery(database);

//This commented line works fine, that means the connection is correct.
//query->exec("SELECT something FROM anything")

//problem lines
query->prepare("{call GetTransactionTest(?,?,?)}");
type="MY_TYPE" //QString
year=0; //int
text.fill(' ',2000); //QString
query.bindValue(0,type);
query.bindValue(1,year,QSql::Out);
query.bindValue(2,text,QSql::Out);
if(query->exec())
{
//success
}
else
{
//Always gets here.
}


}

Because our output parameter needs 2000 charecters i have to do "text.fill(' ',2000) or text.resize(2000)", but
as i resize this to any length greater than 127 the query fails. and lastError() returns the following string


[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead(recv()).[Microsoft][ODBC SQL Server Driver][DBNETLIB]General Network
error. Check your network documentation. QODBC3: Unable to execute statement.

the query succeeds when i write text.fill(' ', 127) (any value less then 127).
All of this was working fine on the same network with same stored procedure in my Qt3.3.6 application.

please.. help... has anyone had this kind of problem before??

wysota
28th June 2007, 13:03
You probably encounter some buffer limit or something like that. It looks like the error is reported by MS SQL and not by Qt, so checking the database log could be a good idea.

nish
29th June 2007, 08:19
thx wysota for your reply...
well, as u know that qt's QSL module has not changed much form qt3 to 4 so i really cant get it...

This small skeleton program runs very well on qt3, but not in qt4. The only thing that i changed during the porting is replacing QSqlDatabase * to QSlDatabase. and i think that should work.

I know that its really hard to find a solution for anyone without looking at the problem themself. I only posted this question here in the hope that someone could have got the similar problem.. i had googled a lot and did not found a similar problem.

And i would like to say....TROLLTECH SUPPORT SUCKS.

thx again for your interest...
keep smilin..

wysota
29th June 2007, 08:45
well, as u know that qt's QSL module has not changed much form qt3 to 4 so i really cant get it...
Did you check the database logs as I asked you to?


This small skeleton program runs very well on qt3, but not in qt4. The only thing that i changed during the porting is replacing QSqlDatabase * to QSlDatabase. and i think that should work.
The problem is that what you think might not be what really is the case. How do you know the SQL module didn't change much between Qt3 and Qt4?


And i would like to say....TROLLTECH SUPPORT SUCKS.
Why is that? What did they tell you?

nish
4th July 2007, 10:28
ok i will tell u why trolltech support sucks...

i emailed them about this a week ago and no reply... i understand that they may need some time to reproduce the error but at least they could have sent an acknowledgement email...

anyhow yesterday i got their reponse... they say...

"i was able to reproduce the problem on MS SQL Server 7.0 but with MS SQL Sever 2005 it all went fine... , just check ur app with SQL 2005 and see if that solves ur problem. I have informed our developers about the bug and u can view it on our task traker with bug id 169394,.. thanks for the report!!"

now when i opened the task traker it says that this bug will be fixed in "Some future release"... Can u imagine my frustration... i have spent my whole week on google thinking that i was doing something wrong in my code. I have just wasted so many programming days on this stupid error...

And now our application is stuck.. i cant do anything... after taking 1500$ for support... what did they telll me?? to buy $$$ MS SQL Sever 2005 ? and even if we buy that then it will take a long time to port all our databases and related asp pages (i dont know anything about SQL so dont know if i am saying it right)

This is not the only case... i was having problems with VC6.. Visual Studio 6 use to crash after installing Qt4 and i reported the bug.. They said the same thing that "we will fix the bug in Qt 4.3.1". We had to buy Visual Studio 2005 for that and as u know about the Manifest Maifesto of VS2005, i had to do a lot of research to be able to run my exe.

Just to add one more.... once i mailed them one query and the support person did not even read my email carefully... and he told me to try a solution which i already tried(and wrote that in the mail), just check out his next reply:-

"I apologize for not spotting this information in your first mail.
Can you also try ........blah blah blah?

Please come back to me if this does not solve the problem."

Guess what!! that "blah blah" was already tried by me and i had written that i my first email...

grrrrrrrr....

i just hate these support personel

wysota
4th July 2007, 11:29
i emailed them about this a week ago and no reply... i understand that they may need some time to reproduce the error but at least they could have sent an acknowledgement email...
I always receive acknowledgements. Check you spam folder.


now when i opened the task traker it says that this bug will be fixed in "Some future release"... Can u imagine my frustration...
Honestly? No, I can't. There are hundreds of open bugs in the database - don't expect the developers (not the support!) to drop everything else they are doing just to fix your problem.


i have spent my whole week on google thinking that i was doing something wrong in my code. I have just wasted so many programming days on this stupid error...
Well, the error is obviously in MS SQL, as I already suggested and what was confirmed by the Trolls. Trolltech will try to overcome the problem from their end, but it has to take time. Why don't you try with a newer version of the database as suggested?


And now our application is stuck.. i cant do anything... after taking 1500$ for support...
I don't think you paid $1500 just for support...


what did they telll me?? to buy $$$ MS SQL Sever 2005 ?
AFAIK you can download it for free as a trial or something. The point is to check whether 2005 works for you or not, not to make it your production environment.


and even if we buy that then it will take a long time to port all our databases and related asp pages (i dont know anything about SQL so dont know if i am saying it right)
No, you're not. I doubt you'd have to change anything.


This is not the only case... i was having problems with VC6.. Visual Studio 6 use to crash after installing Qt4 and i reported the bug..
To Microsoft?


They said the same thing that "we will fix the bug in Qt 4.3.1". We had to buy Visual Studio 2005 for that and as u know about the Manifest Maifesto of VS2005, i had to do a lot of research to be able to run my exe.
But why do you blaim Trolltech support for that?


Just to add one more.... once i mailed them one query and the support person did not even read my email carefully... and he told me to try a solution which i already tried(and wrote that in the mail), just check out his next reply:-

"I apologize for not spotting this information in your first mail.
Can you also try ........blah blah blah?

Please come back to me if this does not solve the problem."

Guess what!! that "blah blah" was already tried by me and i had written that i my first email...
Then mail them again, attaching the original email.


i just hate these support personel
But you have support. And you can always come here and ask for help for free. Trolltech support are great people and they are solving many problems each day. Nobody said they are perfect, but in 90% of the cases they are able to help.

Throwing flames on them won't help you solve your problem. I suggest you download the newer version of MS SQL and check if that helps your application and if you can run your existing code using it. Then you can temporary switch to that version for your immediate development needs and wait for a patch that fixes the original problem between the drivers. Alternatively maybe you can use postgresql or mysql as a temporary solution.

nish
5th July 2007, 07:03
well... i read ur reply a few times... looks like we two dont uderstand each other.. or may be we both have different mindset about trolltech..may be i never had good experinces with them and u always did.

this is not strange.. i am a pro microsoft person and hate mac, i find myself in similar situations when i talk with pro mac people.

hats off to trolltech for producing such a gem of a software. but i still believe that their support needs to be as good as their product. i mail them half a page of email describing each and every bit on my side.. they come up with one liners....may be u get a one page reply always!!

>>This is not the only case... i was having problems with VC6.. Visual Studio 6 use to
>>crash after installing Qt4 and i reported the bug..

>>>To Microsoft?

no... to trolltech.. because qt4 caused the crash not qt3 so its qt's fault.

>>Well, the error is obviously in MS SQL, as I already suggested and what was confirmed
>>by the Trolls. Trolltech will try to overcome the problem from their end, but it has to
>>take time. Why don't you try with a newer version of the database as suggested?

again the same point... everything is same only qt changed from 3 to 4, so the bug is not in SQL server but in qt, and as accepted by trolltech.

>>I don't think you paid $1500 just for support...

well,, this is what my company told me.

>>AFAIK you can download it for free as a trial or something. The point is to check
>>whether 2005 works for you or not, not to make it your production environment.

ok, .. i almost forgot about the trial... i will check wether a trial is available.


>>But why do you blaim Trolltech support for that?

sorry!! my mistake.... i should have blamed MS developers for that.... really they have succeded in making the worst ever visual studio ever(at least for native c++). they want all to code in .net.


>>But you have support. And you can always come here and ask for help for free.

u really live up to ur name "GURU". guru is a hindi word meaning "teacher" and i really learned a thing or two from u in just a short reply..ur absolutely right about the fact that blaming others will not solve ur problem... i was very frustrated because i had a lot of pressure from my company to complete the job quickly. its really hard to explain all this stuff to ur boss.. they all want the work to be complete no matter what.

thx for ur time man...
keep smilin...

wysota
5th July 2007, 10:33
this is not strange.. i am a pro microsoft person and hate mac, i find myself in similar situations when i talk with pro mac people.
Then don't be a "pro anything".


i mail them half a page of email describing each and every bit on my side.. they come up with one liners....may be u get a one page reply always!!
But what more would you expect? "Yes, we confirm this is a bug and a possible workaround is this". Isn't that enough? I'd prefer them spend their time on chasing bugs, not writing essays. But you're right - maybe we just think differently.


no... to trolltech.. because qt4 caused the crash not qt3 so its qt's fault.
This is not so obvious. Qt might have just triggered the real bug.


>>Well, the error is obviously in MS SQL, as I already suggested and what was confirmed
>>by the Trolls. Trolltech will try to overcome the problem from their end, but it has to
>>take time. Why don't you try with a newer version of the database as suggested?

again the same point... everything is same only qt changed from 3 to 4, so the bug is not in SQL server but in qt, and as accepted by trolltech.
No, I'm pretty sure you are wrong here. If the exactly same driver works with a later release of the database, it means that with very good probability something has changed in the database - probably the bug. The fact that Trolltech accepted your report only means that they will try to overcome the problem. They didn't say the problem was on their end (of course I don't say it's not - it can be either way).



>>I don't think you paid $1500 just for support...

well,, this is what my company told me.

http://trolltech.com/products/qt/licenses/pricing

I guess not $1500 and not only for support...


sorry!! my mistake.... i should have blamed MS developers for that.... really they have succeded in making the worst ever visual studio ever(at least for native c++).
The problem with VS6 was that it was released a day before the C++ standard was released so it was based on the beta of the standard and was prepared in a big (bug?) hurry.


i was very frustrated because i had a lot of pressure from my company to complete the job quickly. its really hard to explain all this stuff to ur boss.. they all want the work to be complete no matter what.
Can't you just focus on some other aspect of the application until the driver problem is resolved? If not, then tell your boss you have to wait, unless he wants to buy the new database ;)

BTW. That's one of the problems of binding yourself too much to a specific (proprietary) vendor.

mm78
5th July 2007, 17:06
Does Trolltech explicitly say that they support SQL Server 7.0?

SQL Server 7.0 is rather old now, and only extended support is available from Microsoft:
http://support.microsoft.com/kb/912251

SQL Server 2005 Express Edition is free and you can download it from:
http://msdn.microsoft.com/vstudio/express/sql/

You may have valid reasons to stay with SQL Server 7.0, but upgrading to a more recent version might not be a bad idea. I'm sure the bug you ran into isn't the only difference between 7.0 and a newer version.

nish
6th July 2007, 08:03
well... thx for ur time ppl..
the management has posponed this application development and i am shifted to another project... such a relief...

now i have to leave the user friendly VC compiler move to stupid xcode on mac...

anyways.. thx again...
bye

mm78
6th July 2007, 20:06
Just a final thought: Qt doesn't communicate directly with the database server, but trough an ODBC driver. Updating the ODBC driver might solve your problem.

nish
7th July 2007, 10:16
so can ya please tell me.. where can i find the updated driver... and dont tell me that i have to update it myself.

mm78
9th July 2007, 11:42
:eek: Yeah sure, just give me your address and a ticket and I'll fly over tomorrow morning to help you download and install it.

Or you can save yourself some money and have a look at:
http://msdn2.microsoft.com/en-us/data/aa937733.aspx

I'm not saying this is the solution though, just that it might solve your problem. I guess you'll have to try it to find out.

nish
12th July 2007, 06:53
hey.. cool down man...

and ofcourse if u want to visit my home,, most welcome. But the prob is that i am a poor guy living in one of the poorest countries of the world. so u have to arrange a ticket urself.

ok jokes apart.. i had a look at the link, but it says about SQL2005 and not 7.0. Anyways.. we are upgrading our system to SQL2005 so thx for the info man.

navab
16th January 2009, 09:11
HI,
I also encountered similar problem. Found no sulotion yet. I have also reported to Qt guys . No response yet.