Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

MSSQL SQL Server library

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-22-2010, 01:37 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default MSSQL SQL Server library

This library, a tidied up version of http://www.basic4ppc.com/forum/addit...l-library.html allows access to SQL Server databases.

A rudimentary help file is included that describes the available methods and properties but it is expected that you already know what do do in order to connect to a SQL Server instance because I don't! However you do need System.Data.SqlClient.Dll from post #8 of this thread on your device.

EDIT :- Version 1.7 posted. See post #8 for details.

EDIT :- Version 1.8 posted. See post #10 for details.

EDIT :- Version 1.9 posted. See post #13 for details.

EDIT :- Version 2.0 posted. See post #32 for details.
Attached Files
File Type: zip System.Data.SqlClient3.0.3600.0.zip (73.9 KB, 139 views)
File Type: zip MSSQL2.0.zip (10.5 KB, 94 views)
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.

Last edited by agraham : 07-14-2011 at 09:42 AM.
Reply With Quote
  #2 (permalink)  
Old 07-22-2010, 03:49 PM
Junior Member
 
Join Date: Jul 2010
Posts: 39
Default

Great job Andrew! and nice documentation.

Thank you.
Reply With Quote
  #3 (permalink)  
Old 07-23-2010, 12:58 PM
Junior Member
 
Join Date: Jul 2010
Posts: 39
Default

Hi, i am back just to ask something.

Is there any chance to add a property (String or Number) e.g. "RowCount", to know the rows that the query returned before reading the data ?

I don't know if function ReadRemainingRows is for this use, but i can't work with it.

Thanks.
Reply With Quote
  #4 (permalink)  
Old 07-23-2010, 03:10 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by georgea View Post
Is there any chance to add a property (String or Number) e.g. "RowCount", to know the rows that the query returned before reading the data ?
I looked to do that but there doesn't seem to be any way of finding that out without reading to the end of the table. I think it is the same with SQLite.

Quote:
I don't know if function ReadRemainingRows is for this use, but i can't work with it.
It's a convenience to read the entire table at once and the length of the returned array will tell you how many rows. Why can't you use it?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #5 (permalink)  
Old 07-23-2010, 07:58 PM
Junior Member
 
Join Date: Jul 2010
Posts: 39
Default

Sometimes you may need to know how many rows the query returns, before you read the query. So, if you read all the data till the end of the table just to count the rows then if you re-read the Mssql.Advance it returns False and you can't read it.

As for the ReadRemainingRows, i tryied to test it but it always returns ArrayLen = 1 and when i try to read it, it seems to be empty or null.

One (dump) solution is before the main query you plan to execute, to execute a "Select Count({field}) As Rowcount From {table}" and then ReadField("Rowcount") to know how many rows you 'll get. I know that you have to execute 2 queries everytime but i see it as the only way.
Reply With Quote
  #6 (permalink)  
Old 07-23-2010, 08:15 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by georgea View Post
As for the ReadRemainingRows, i tryied to test it but it always returns ArrayLen = 1 and when i try to read it, it seems to be empty or null.
There's probably a bug in it then . What does LastError return after you have executed ReadRemainingRows? The array should also contain the error string at index (0,0).
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #7 (permalink)  
Old 07-23-2010, 09:01 PM
Junior Member
 
Join Date: Jul 2010
Posts: 39
Default

The following is the test code which returns me normally 8 rows:

Code:
mssql1.ExecuteQuery("Select nickname From Employees")
array2() = Mssql1.ReadRemainingRows
Msgbox(ArrayLen(array2()))
Msgbox(array2(0,0))
The first MsgBox returns 1 and the second MsgBox i get System.IndexOutOfRangeException: Index Out Of Bounds.MSSQL.MSSQL.ReadRemainingRows()

Also, after ReadRemaingRows the Mssql.Advance returns always False and i can't use ReadField().
Reply With Quote
  #8 (permalink)  
Old 07-24-2010, 07:57 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Version 1.7 now posted which (hopefully) fixes the the bug in ReadRemainingRows.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #9 (permalink)  
Old 07-24-2010, 09:07 AM
Junior Member
 
Join Date: Jul 2010
Posts: 39
Default

Goodmorning.

I tested Version 1.7 and i noticed that RemainingRows now return as ArrayLen the number of rows retrieved + 1. However the main issue is that after executing RemainingRows, the Advance method returns false and you can't read the data. Also, Array(0,0) returns the same error but this is not an issue.

Thank you.
Reply With Quote
  #10 (permalink)  
Old 07-24-2010, 09:39 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by georgea View Post
RemainingRows now return as ArrayLen the number of rows retrieved + 1.
There was another bug that I missed in ReadRemainingRows which was using a wrong property to size the array. Corrected in version 1.8.
Quote:
However the main issue is that after executing ReadRemainingRows, the Advance method returns false and you can't read the data.
That is correct behaviour. It is the same as you doing multiple ReadRows. The data is in the two dimensional array that is returned by ReadRemainingRows. You can use ReadRemainingRows immediately after ExecuteQuery to get the whole table or use Advance and ReadRow to get the data one row at a time. Using ReadRemainingRows after using Advance and ReadRow one or more times will return only the data in the unread part of the table. It seems to be common to SQL databases that tables returned from queries can only be read once in a forward direction.
Quote:
Also, Array(0,0) returns the same error but this is not an issue.
I don't understand this unless you are trying to execute ReadRemainingRows again in which case it is expected behaviour as the table has been read to the end.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
MSSQL lib and BLOB zdenkot Questions (Windows Mobile) 2 04-27-2010 12:54 PM
NetUDP server and client library agraham Additional Libraries 2 07-31-2009 10:42 AM
Getting access to an MSSQL database lairdre Questions (Windows Mobile) 5 11-17-2008 08:59 PM
Mssql Sascha K. Questions (Windows Mobile) 1 06-05-2008 03:46 PM
New server Erel Forum Discussion 12 11-06-2007 04:21 PM


All times are GMT. The time now is 07:16 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0