Looking for library to access MS SQL server

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
jqn
User
User
Posts: 97
Joined: Fri Oct 31, 2003 3:04 pm

Looking for library to access MS SQL server

Post by jqn »

Hi,
Someone know a DLL or embeded LIB to access MS SQL server, using CallFunction() or CallCFunction()?.

I'm using libmysql.dll to access MySQL server, and it runs fine. I'm looking for some similar library.

Free, of course, I know already www.sqlapi.com by $299.

Best Regards
JOAQUIN
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
jqn
User
User
Posts: 97
Joined: Fri Oct 31, 2003 3:04 pm

Post by jqn »

Thanks, Fangbeast. But I'm ALREADY accessing MySQL.

I'm need same access to MicroSoft SQL server 2000. I'm looking for a dll similar to libmysql.dll.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

jqn wrote:Thanks, Fangbeast. But I'm ALREADY accessing MySQL.

I'm need same access to MicroSoft SQL server 2000. I'm looking for a dll similar to libmysql.dll.
I seem to remember some code by Rings at purearea.net that would access any database. Try there or a link from there in the PBOSL libraries.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

You could try the SQL Native client DLL that comes with SQL server 2005. I heard it is backwards compatible with SQL 2000.
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Isn't it possible to connect using ODBC?
Tranquil
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Hi jqn,

I use MySQL without any additional library. Just created a SystemDSN to MySQL and used PB-code like this (3.94):

Code: Select all

If OpenDatabase(#MySQL, mysqlUseDB.s, Username.s, Password.s) = 0
  MessageRequester("error", "MySQL-Database not available!" + #CR$ + #CR$ + DatabaseError(), #MB_ICONERROR)
  ProcedureReturn #False
EndIf

Query.s = "SELECT * FROM Table WHERE Field = Value"
If DatabaseQuery(Query.s) = 0
  MessageRequester("error", "MySQL-Error: " + DatabaseError() + " using query: '" + Query.s + "'", #MB_ICONERROR)
  ProcedureReturn #False
EndIf

(...)
There is surely no library needed!

Kukulkan
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Tranquil wrote:Isn't it possible to connect using ODBC?
Yes, but only if you dont mind the slow down.
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Yes, but only if you dont mind the slow down.
I know a lot of high performance applications using ODBC like document management systems or enterprice ressource planning. Most time, the speed is a result of your programming skills, right indexes and good logic.

But if you mean ODBC is to slow, you have to choose another method. There I can't help you. Sorry.

Kukulkan
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

ODBC is a so called 'thin' wrapper, it won't be slow.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

My apologies, I should have explained myself better.

Some people takes to practice to connect - execute sql - disconnect. When doing this through odbc in PHP, it is slow. however, having a persistant connection, it is the same speed (afaik) as using the mysql native dll.

So I actually agree too :) For persistant connections odbc and native dlls are definately compariable. but for the multiple connects/disconnects, I have found odbc slower ..

Thus is another reason why forums such as PHPBB, WWF, VB, etc have an option for persistant db connections. The speed increase is huge :)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

On another note, if you head over to the docs found @ ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.SQL.v2005.en/dataacc9/html/69889a98-7740-4667-aecd-adfc0b37f6f0.htm

It mentions the header files found @ %PROGRAM FILES%\Microsoft SQL Server\90\SDK can be used. Specifically .. sqlncli.h :) I know there are some people here who have been successfull in converting over C headers to PB includes.
e2robot
New User
New User
Posts: 5
Joined: Sun Dec 25, 2005 11:17 am
Location: Australia

Post by e2robot »

I had the same problem and run a vb script from Purebasic to make the DSN in the ODBC control panel. Then use standard Purebasic database commands.

I basically cut and paste the code from the following site into a file called dsn.vbs

http://www.microsoft.com/technet/script ... y1110.mspx

I just use something like

Code: Select all

RunProgram("dsn.vbs","", "", 1 | 2)  
to call the script.

Phil
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Well, it can be easily done with purebasic.

Creating/Removing DSN:
http://msdn.microsoft.com/library/defau ... source.asp

Code: Select all

; flype, juil 2006 

Enumeration 1 
  #ODBC_ADD_DSN            ; Ajoute une source de données utilisateur. 
  #ODBC_CONFIG_DSN         ; Configure/Modifie une source de données utilisateur existante. 
  #ODBC_REMOVE_DSN         ; Supprime une source de données utilisateur existante. 
  #ODBC_ADD_SYS_DSN        ; Ajoute une source de données système. 
  #ODBC_CONFIG_SYS_DSN     ; Configure/Modifie une source de données système existante. 
  #ODBC_REMOVE_SYS_DSN     ; Supprime une source de données système existante. 
  #ODBC_REMOVE_DEFAULT_DSN ; Supprime la source de données définies par défaut. 
EndEnumeration 

#ODBC_DRIVER_MSACCESS = "Microsoft Access Driver (*.mdb)" 

Procedure.l MSAccess_AddConnection(name.s, database.s, hwnd.l = #Null) 
  
  Protected attrs.s 
  
  attrs + "UID="         + ";" 
  attrs + "PWD="         + ";" 
  attrs + "DSN="         + name + ";" 
  attrs + "DBQ="         + database + ";" 
  attrs + "FIL="         + "MS Access;" 
  attrs + "Driver="      + "ODBCJT32.DLL;" 
  attrs + "DefaultDir="  + GetPathPart(database) + ";" 
  attrs + "Description=" + FormatDate("Créé le %dd-%mm-%yyyy, %hh:%ii:%ss;", Date()) 
  
  ReplaceString(attrs, ";", #NULL$, 2) 
  
  ProcedureReturn SQLConfigDataSource_(hWnd, #ODBC_ADD_DSN, #ODBC_DRIVER_MSACCESS, attrs) 
  
EndProcedure 

Procedure.l MSAccess_RemoveConnection(name.s, hwnd.l = #Null) 
  
  ProcedureReturn SQLConfigDataSource_(hWnd, #ODBC_REMOVE_DSN, #ODBC_DRIVER_MSACCESS, "DSN="+name) 
  
EndProcedure 

If InitDatabase() 
  
  DSN.s = "pbtest" 
  
  If MSAccess_AddConnection(DSN, "c:\test.mdb") 
    
    If OpenDatabase(0, DSN, "", "") 
      
      If DatabaseQuery(0, "SELECT NOW") 
        If NextDatabaseRow(0) 
          Debug GetDatabaseString(0, 0) 
        EndIf 
      EndIf 
      
      If DatabaseQuery(0, "SELECT * FROM personne") 
        While NextDatabaseRow(0) 
          Debug GetDatabaseString(0, 0) 
          Debug GetDatabaseString(0, 1) 
          Debug GetDatabaseString(0, 2) 
        Wend 
      EndIf 
      
    EndIf 
    
    MSAccess_RemoveConnection(DSN) 
  
  EndIf 
  
EndIf
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

Kukulkan wrote:Hi jqn,

I use MySQL without any additional library. Just created a SystemDSN to MySQL and used PB-code like this (3.94):
(...)
There is surely no library needed!

Kukulkan
My 2 cents... this will not work unless the client has loaded MyODBC - which is what I primarily do when I build database driven PB apps. I usually make the connect string a registry setting so the final app could use any type of database - but I find MySQL quite capable for all the stuff I do.
-Beach
Post Reply