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.

MS SQL Library

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-04-2008, 10:46 PM
Newbie
 
Join Date: Sep 2008
Posts: 6
Default MS SQL Library

MSSQLRemote is a basic library which allows you to access a corporate MS SQL Server. Why would you want to do this?, well in my case it's for wireless hand held devices used in a warehouse environment.

Warning This is not currently in production and as it is my first library there are likely bugs and probably there are better ways of doing things. In particular the BeginTransaction and related functions are not fully tested.

Usage as follows:

LastError - Returns the last exception as string

New - Sets up the Connection and returns True or False
Open(ConnString) - Opens a database where ConnString is something like "Persist Security Info=False;Integrated Security=False;Server=CWS-MARK, 1433; initial catalog=ArrowDemo; user id=sa; password=pass;" Returns True or False depending on success.

Close - Closes the current connection

ExecuteNonQuery(QueryString) - Returns True or False. QueryString like "Update Invoices Set StatusFlag = 'X' Where Reference = '1234'"

ExecuteQuery(QueryString) - Returns True or False. QueryString like "Select * From Invoices"

After ExecuteQuery the following are valid:
  • Data - Returns True or False. Step Through result set one row at at a time ie. (Do While Data - i = ReadRow - Loop)
  • Read(FieldName) - Returns single field as string from current row
  • ReadRow - Returns string array of current row

OR
  • BuildResultSet - Will read entire result set and return True or False if data.
  • GetResultSet - Returns entire result set as Array
Fields - Returns number of fields in current result set as integer
Rows - Return number of rows in current result set (only after BuildResultSet)

FieldInfo - Returns Array of field name and field type for current result set

BeginTransaction - Returns True or False
Commit - returns True or False
RollBack - returns True or False
TransactionDispose - returns True or False

Use BuildResultSet and GetResultSet with care as they use Array Redim. Large record sets may/will cause performance problems. Unfortunately CF and also basic4pcc do not appear to support multi dimensional arraylists? If any has any further information or ideas it would be most appreciated.

Requires System.Data.SqlClient.Dll. Tested on SQL Server 2005 should work on 2000 and Express.

Cheers

Mark S
Attached Files
File Type: zip MSSql.zip (2.9 KB, 307 views)
Reply With Quote
  #2 (permalink)  
Old 10-06-2008, 03:28 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 citywest View Post
Unfortunately CF and also basic4pcc do not appear to support multi dimensional arraylists? If any has any further information or ideas it would be most appreciated.
The .NET Common Language Runtime does not support multi-dimensional arraylists. I've looked at your code and in fact you are doing the same as what an Arraylist does when it runs out of space. An Arraylist is based on an underlying fixed length array and, like you it,allocates a new longer array and copies the existing items into it. Unlike you it usually doubles the array length each time. The underlying .NET array copy mechanism appears to be a native code function call and is probably a memory block copy so your implementation is probably reasonably efficient. You could only get better if you knew how many rows the query returned but that's getting out of my depth as I don't do database work.
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 08:45 PM
Newbie
 
Join Date: Sep 2008
Posts: 6
Default

Thanks for the information agraham.

The sqldatareader is a forward reader only, so you have to read through the entire result set before you can determine the number of rows.

I guess a better way might be to allow the array size to be specified by the caller program.

Regards

Mark S
Reply With Quote
  #4 (permalink)  
Old 12-12-2008, 06:33 PM
Newbie
 
Join Date: Dec 2008
Posts: 8
Default Can you provide any basic4ppc sample code?

I am a newbie for basic4ppc. Can you provide any basic4ppc sample code about using MSSQL.DLL?
Thanks,
Mike

Last edited by UnknownArt : 12-12-2008 at 06:50 PM.
Reply With Quote
  #5 (permalink)  
Old 03-23-2009, 08:07 PM
Newbie
 
Join Date: Jan 2009
Posts: 3
Default Conect to MS SQL server

Alguien tiene algun ejemplo de conectar a un sqlserver 2000 usando System.Data.SqlClient.dll. Gracias a todos
Reply With Quote
  #6 (permalink)  
Old 04-15-2009, 01:31 AM
Newbie
 
Join Date: Sep 2008
Posts: 6
Default

Been very busy lately so have only just seen this

A small code snippet that should get you going:

'Select All Records From Table CodMast and in Database ArrowDemo. Display the Fields named Record_Type and Description

msql1.New1
msql1.Open("Persist Security Info=False;Integrated Security=False;Server=CWS-MARK, 1433; initial catalog=ArrowDemo; user id=sa; password=1234;")

msql1.ExecuteQuery("Select * From CodMast Where Record_Type = 'LS' Order By Code")

Do While msql1.Data
Msgbox(msql1.Read("Record_Type") & " " & msql1.Read("Description"))
Loop

msql1.Close

'Update Table CodMast in Database ArrowDemo

msql2.New1
msql2.Open("Persist Security Info=False;Integrated Security=False;Server=CWS-MARK, 1433; initial catalog=ArrowDemo; user id=sa; password=1234;")

msql2.ExecuteNonQuery("Update CodMast Set Description = 'TEST DESCRIPTION' Where Record_Type = 'LS' And Code = 'EF')
msql2.Close

Cheers,

Mark S.
Reply With Quote
  #7 (permalink)  
Old 08-04-2009, 02:49 PM
Newbie
 
Join Date: Aug 2009
Posts: 9
Default .NET Compact Framework

Hi,

I download the MSSQL Library and made a litter program to test it. What it does is create a new connection and try to open it, but before the form appear in the Device (HTC Touch, WM6 Professional) an error arise saying that it require a new .Net Compact Framework, it has installed the 2.0 CF, any way I install the 3.5 CF and the error continue.

What is wrong?

Rafael Liriano
SONEINSA
Reply With Quote
  #8 (permalink)  
Old 08-04-2009, 04:23 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

This library depends on another dll: System.Data.SqlClient.Dll

I've attached it.
You will need to copy it to the device together with MSSQL.dll.
Attached Files
File Type: zip System.Data.SqlClient.zip (62.0 KB, 119 views)
Reply With Quote
  #9 (permalink)  
Old 08-06-2009, 05:15 PM
Newbie
 
Join Date: Aug 2009
Posts: 9
Default Can not Open Remote wireless SQL Server

Hi,

Thanks for the answer, now the application run after copy the System.Data.SqlClient.Dll file and the MSSQL.Dll.!!!

Now the my problem is that the following code does not open the connection to the SQL Server, I try SQL Server 2005 and SQL Server 2000, I try to connect wireless from a laptop to XPS server and the connection is Ok, but when try to do it from the Device (HTC Touch, WM6 Professional) to the same XPS Server then cnDatos.open return False.

When I click the button the .Open return False. What I'm doing wrong?, What I'm missing?. Please help me, because connecting to SQL Server is very necessary to my project. If I connect to the PC that has the XPS SQL Server via the file explorer from the Device I see the sharing folder from the PC, I mean that the wireless connection is ok with the PC.

Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
    cnDatos.New1
End Sub

Sub Button1_Click
    
If cnDatos.Open("Persist Security Info=False;Integrated Security=False;Server=XPS,1433; initial catalog=windip; user id=sa; password=12345;"Then
        
Msgbox("Conexion exitosa!!!","My First Program",cMsgboxYesNo,cMsgboxHand)
    
Else    
        
Msgbox("Conexion ERRONEA!!!","My First Program",cMsgboxYesNo,cMsgboxHand)
    
End If

End Sub

Thanks in advanced

Rafael Liriano
SONEINSA
Reply With Quote
  #10 (permalink)  
Old 08-06-2009, 07:39 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Did you try to see the value of cnDatos.LastError?
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
Door library (Beta) - Special library Erel Official Updates 60 01-13-2011 11:23 AM
Merging Outlook library and Phone library Erel Official Updates 11 09-15-2010 09:22 AM
PhoneticAlgorithms Library (ex-StringComparison Library) moster67 Additional Libraries 10 11-11-2008 07:46 PM


All times are GMT. The time now is 06:26 AM.


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