Click here to Skip to main content
15,860,972 members
Articles / Mobile Apps

Administrate SQL Server2000 from Pocket PC

Rate me:
Please Sign up or sign in to vote.
4.50/5 (10 votes)
18 Feb 2005CPOL3 min read 92.2K   387   46   21
This article demonstrates administrating SQL Server 2000 from Pocket PC on the fly.

Sample Image - AdminSQLfromPocketPC.jpg

Introduction

I am a little crazy about writing mobile applications using .NET CE. This article describes about administrating SQL Server 2000 from Pocket PC with the help of Web Services. Using web service I can administrate SQL Server 2000 on the fly.

Client Requirements.

  1. Pocket PC with Microsoft Windows CE powered.
  2. Microsoft .NET Compact Framework 1.0.

Server Requirements.

  1. Microsoft .NET framework 1.1.
  2. MS SQL server 2000 with SP3 or above.
  3. IIS 5.0.

Background

Sometime I might away from my SQL Server or I might have be traveling somewhere. In that time, I thought about how could I control my SQL Server from there. Then I got an idea why not to try with a Pocket PC. When I stated doing the application, I faced problem in connecting to my remote SQL Server from Pocket PC. Then I look around and thought web service might be the right solution. I used web service as middle tire to interconnect my Pocket PC and SQL server. Finally, I am able to achieve that.

This is a beginning. In this, we can connect to SQL Server and manipulate query processes like how we do in Query analyzer.

In future version, I am planning to do like Desktop Enterprise Manager. If you can help me to achieve this, then you are most welcome.

Using the code

Download the source code as ZIP file. Unzip it, and in that you can find two folders named WSSQLsrv2000 and ControlSQLsrv2000.

WSSQLsrv2000 folder contains Web services, which will be consumed by the Pocket PC. Open Internet Information Services Manager (IIS) create a virtual folder under the Default Web Site directory. Set the physical file location as WSSQLsrv2000 folder path. Give write permission to the Virtual folder.

Find creating virtual folder details over here.

ControlSQLsrv2000 folder contains Windows CE application. You can compile and execute it in Emulator or deploy it in your Pocket PC.

When you execute the Pocket PC application you will be prompt for SQL server details to connect.

When you click on connect, the following code will be executed.

Login

try
{
    UpdateStatus("Connecting to the database...");
    oLoginInfo.sServer = txtServerName.Text;
    oLoginInfo.sLoginName = txtLoginName.Text;
    oLoginInfo.sPassword = txtPassword.Text;
    oLoginInfo.sDatabase = "";
    ConnectDB oConDb = new ConnectDB();
    if (oConDb.fnConnect(txtServerName.Text ,txtLoginName.Text ,txtPassword.Text))
    {
       UpdateStatus("Connected...");
       frmMain ofrmMain = new frmMain();
       ofrmMain.FillTreeView(oLoginInfo);
       ofrmMain.Show();
       this.Hide();
    }
    else
    {
       UpdateStatus("Not Connected..."); 
       .....

The following code in Web service will be executed.

[WebMethod] public bool fnConnect(string sDataSource, string sUserid, 
                                                     string sPassword)
{
   //To check the connection status with given details
   oLoginInfo.sServer = sDataSource;
   oLoginInfo.sLoginName = sUserid;
   oLoginInfo.sPassword = sPassword;
   oLoginInfo.sDatabase = "";
   if (oCon.fnConnectStatus(oLoginInfo))
   {
     //Save the details if the connection status is true for further manupulation
     SetDBConfigSettings(sDataSource,sUserid,sPassword);
     return true;
   }
   else
   { 
     //Connection failed in various reasons
     return false;
   }
 }

ConnectDB is a class written in web service. Here we are creating the object to that class and consuming its Web method fnConnect(). When this function is called, the web services receive the request and connects to the SQL server. Once the connection was success then the application will show the Server details.

We can populate the databases in two ways.

  1. Select Databases, tap and hold for few seconds and a pop up menu will appear with two options Refresh and Query Analyser. In that Select Refresh.

    Populate Database 1

  2. Select Database and select File -> Refresh From the main menu.

    Sample screenshot

Once you select the refresh option, the entire databases will be listed. Select the Database which you want to manipulate and choose the Query Analyser option based on the above two methods. Once you select it you will be redirected to another screen.

Main menu details

  1. Refresh – Reload all the databases under the server.
  2. Query Analyser – Select particular database under Databases Directory and do query manipulation by selecting this option.
  3. Re-Login – Exit from current server and login into different server.
  4. Exit – Exit and close the application.

In that text box enter the query you want to execute. For example, type

SQL
Select * from authors

Select the statement to execute. And tap on run to execute the statement. The results will be populated in the grid.

The results will be populated like this:

Results

Points of interest

When you deploy the web service in your local PC, you have to change the URL from http://localhost to http://<ipaddress> in reference.cs under WSSQLsrv2000 folder. Otherwise the Pocket PC can’t consume the service.

You can find some of my articles over here.

History

Initial version 0.1.0

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
Called as Rasheed. Completed Master of Computer science. Working as Senior Consultant in Chennai, India.

Try to achive in different stream

Comments and Discussions

 
Generalweb error Pin
cathy200718-Mar-08 18:38
cathy200718-Mar-08 18:38 
QuestionRasheed1979, Pin
naimish.s4-Nov-07 23:28
naimish.s4-Nov-07 23:28 
Questionport 1433 and pocket pc Pin
q_lozano4-Sep-07 11:50
q_lozano4-Sep-07 11:50 
Generalpda not connect Pin
GVerris7-Aug-07 12:24
GVerris7-Aug-07 12:24 
QuestionError when Add web reference Pin
yummy_yummy6-Apr-07 14:29
yummy_yummy6-Apr-07 14:29 
GeneralGot WebException after make a connection Pin
PrasertHong26-Mar-07 22:51
PrasertHong26-Mar-07 22:51 
Generalconnect with my protal database - mysql Pin
surpatel7810-Mar-07 2:20
surpatel7810-Mar-07 2:20 
GeneralRe: connect with my protal database - mysql Pin
rasheed197920-Mar-07 0:38
rasheed197920-Mar-07 0:38 
QuestionConnect from PPC to SQL SERVER 2000/2005 (On desktop) Pin
thesking31-Jan-07 2:22
thesking31-Jan-07 2:22 
AnswerRe: Connect from PPC to SQL SERVER 2000/2005 (On desktop) Pin
surpatel7810-Mar-07 2:19
surpatel7810-Mar-07 2:19 
Questionsecurity Pin
diana_01_kdr19-Jan-06 5:38
diana_01_kdr19-Jan-06 5:38 
QuestionWill Bluetooth work for it ?? Pin
TheFrnd30-Dec-05 18:30
TheFrnd30-Dec-05 18:30 
AnswerRe: Will Bluetooth work for it ?? Pin
rasheed19791-Jan-06 20:41
rasheed19791-Jan-06 20:41 
Generalerror when deploy to pocket pc Pin
diana_01_kdr20-Dec-05 22:38
diana_01_kdr20-Dec-05 22:38 
GeneralRe: error when deploy to pocket pc Pin
rasheed197922-Dec-05 17:14
rasheed197922-Dec-05 17:14 
Questionsql server ce &amp; wifi Pin
diana_01_kdr19-Dec-05 6:43
diana_01_kdr19-Dec-05 6:43 
AnswerRe: sql server ce &amp;amp; wifi Pin
rasheed197919-Dec-05 17:23
rasheed197919-Dec-05 17:23 
GeneralAbout Application Pin
BlueCalling20-Jul-05 6:51
BlueCalling20-Jul-05 6:51 
Generalhelp me how to build such applications Pin
virgo*11-Jul-05 8:23
virgo*11-Jul-05 8:23 
GeneralRe: help me how to build such applications Pin
rasheed197912-Jul-05 0:05
rasheed197912-Jul-05 0:05 
Generalhep me develop such application Pin
virgo*11-Jul-05 8:08
virgo*11-Jul-05 8:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.