how to connect to sql express 2005/2018/2014 ?

Windows specific forum
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

how to connect to sql express 2005/2018/2014 ?

Post by sartic »

please post example. thx
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
User avatar
bbanelli
Enthusiast
Enthusiast
Posts: 543
Joined: Tue May 28, 2013 10:51 pm
Location: Europe
Contact:

Re: how to connect to sql express 2005/2018/2014 ?

Post by bbanelli »

sartic wrote:please post example. thx
If you don't have one, install Microsoft ODBC driver.

https://www.microsoft.com/en-us/downloa ... x?id=53339

After that, create a User DSN via Control Panel's Administrative Tool Data Sources (ODBC) (or you can even do it directly via PB, see this great example) and simply use PB's database ODBC instructions from documentation.

Code: Select all

UseODBCDatabase()
;Makeconnection("ODBC Driver 13 for SQL Server", "Dsn=myDSNName;Server=tcp:myAzureName.database.windows.net,1433;Database=myDbNAME;Encrypt=yes;TrustServerCertificate=no;") ;Optional
Define.s dbName = "myDSNName", dbUser = "yourDBName", dbPass = "yourDBPass"
Define.i dbHandle
dbHandle = OpenDatabase(#PB_Any, dbName, dbUser, dbPass, #PB_Database_ODBC)
If dbHandle
  ;Do your SQL stuff as you normaly would...
EndIf
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/
swan
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 03, 2004 9:04 am
Location: Sydney Australia
Contact:

Re: how to connect to sql express 2005/2018/2014 ?

Post by swan »

Is the database local or remote ?
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

Re: how to connect to sql express 2005/2018/2014 ?

Post by sartic »

it is local.i will explore it this weekend if i solve problem with crush in closewindow()
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: how to connect to sql express 2005/2018/2014 ?

Post by TI-994A »

sartic wrote:please post example...
Perhaps this little tutorial might help:

> A Simple ODBC Primer
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply