SQL Server MSDE OSQL
DI Management Services, Sydney, Australia  
DI Management Services is a database design and business systems consultant based in Sydney, Australia ...more... We analyse your business management systems and design custom software solutions + database design + programming
Back Home Page Next
===
 

OSQL Interface to MSDE

This is a simple graphical interface you can use to send T-SQL commands to MSDE from an Access database. It's written in Access 97 but should convert easily to its more recent siblings. Download the project MSDEFromACC.zip (24 kB) here. All the necessary code is behind the form.

It's no replacement for the fancy interfaces that come with the full NT-version, but it stops the results going off the page in the plain DOS version.

MSDE must be running on your local machine and it assumes user sa with no password.

The screen dumps following show:

  1. A simple command to find out the current version
  2. Creating a database
  3. Creating a table
  4. Using the SELECT Command - note how you can specify the database name in the bottom text box.
SQL Server Version Create a Database Create a Table SQL Server SELECT command
  

The program works by creating the OSQL DOS command from your input, calling it from the DOS shell, and then reading in the results from the output file. It uses two temporary text files, ~SqlIn.txt and ~SqlOut.txt, and attempts to clean up some of the extraneous characters that OSQL produces before displaying the results. The key instructions are:

' Create a command string to call OSQL
sCommand = "OSQL /Usa /P /n /w 80 /i " & msInFile & " /o " & msOutFile

' Is a database specified?
If Len(Me.txtDatabase & "") > 0 Then
    sCommand = sCommand & " /d " & Me.txtDatabase
End If

' Delete the output file
If Len(Dir(msOutFile)) > 0 Then
    Kill msOutFile
End If

' Execute DOS command that outputs text to OutFile
varRet = Shell(sCommand)

Originally, I'd tried to use the Rich Text control. It made some things easier, but made distributing the project the usual nightmare you have with Active-X controls. Also, whenever I tried to enter a command with an asterisk in it, such as select * from mytable, it kept reverting to some Office autocorrect function that I couldn't turn off. So that's why it uses plain old text boxes.

For more information Contact DI Management.    Return to the SQL/MSDE Page.    [Top]Return to top of page

 
===
Copyright © 2002 DI Management Services Pty Limited ABN 78 083 210 584 Sydney, Australia. www.di-mgt.com.au. All rights reserved.

Home | What We Do | Services | Our Approach | About Us | Projects | Tips | Links | Cryptography | CryptoSys API | About This Site | Contact | Email Us