Jump to content
argumentum

[Solved] MS SQL Express 2014 - Connect

Recommended Posts

argumentum

I'm with MS SQL Express 2014.
Went to the wiki - Databases_and_web_connections but I can't find a way =/

the strings I've got are:

ODBC;DSN=eFilmWorkstation;Trusted_Connection=Yes
ODBC;DSN=eFilmWorkstation;UID=sa;PWD=eFilmWS30
"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE';"

A working example ? ( that would run if you had the db )
Or, advise in a UDF to use and how to use it ?

I don't care to write, just to read.

Thanks
 

Edited by argumentum

Share this post


Link to post
Share on other sites
argumentum

found the solution :) 

#include <_sql.au3>
#include <array.au3>

Opt ("trayIconDebug",1)

Msgbox(0,"","Start the Script and load the error handler")
 _SQL_RegisterErrorHandler();register the error handler to prevent hard crash on COM error

$oADODB = _SQL_Startup()
If $oADODB = $SQL_ERROR then Msgbox(0 + 16 +262144,"Error 1",_SQL_GetErrMsg())

If _sql_Connect($oADODB,"localhost\SQLEXPRESSEFILM","eFilmWorkstation","sa","eFilmWS30") = $SQL_ERROR then
    Msgbox(0 + 16 +262144,"Error 2",_SQL_GetErrMsg())
    _SQL_Close()
    Exit
EndIf

Local $aData,$iRows,$iColumns;Variables to store the array data in to and the row count and the column count
$iRval = _SQL_GetTable2D(-1,"SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE';",$aData,$iRows,$iColumns)
If $iRval = $SQL_OK then _arrayDisplay($aData,"2D  (" & $iRows & " Rows) (" & $iColumns & " Columns)" )
_SQL_Close()

 

Share this post


Link to post
Share on other sites
mLipok

Try my ADO.au3 udf. 

Look in my signature. 

 

  • Thanks 1

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • gritts
      By gritts
      I am attempting to create a script which will poll a SQL database that is part of our internal server monitoring application. The results would then be pushed to the local growl client on my desktop. I am successful at querying the SQL database using the SQL UDF and can send growl notifications fine as well...

      What I run into is "Syntax error converting datetime from character string." when I try to query the database with the value from a previous query. (My appologies for making this sound confusing)

      For example, I query the database and return the results into a 2D array. I can display the results fine with "_ArrayDisplay". I then take the results from the query and using the next to last row from the results, get the value from the datetime column.


      $tmpDate = String($aData[$iRows-1][1]) MsgBox(0,"Date",$tmpDate)

      It is when I take the value in $tmpDate and attempt to search with it that I get the syntax error above.


      $iRval = _SQL_GetTable2D(-1, "select * from dbo.AllpagesToday WHERE PageRecip = 'SERVER_OC1' OR PageRecip = 'SERVER_ONCALL' AND Date > '" & $tmpDate & "' ORDER BY Date;", $aData, $iRows, $iColumns)
      I have also attempted to convert the date format from: 20120319090303 to 2012-03-19 09:03:03.000 to no avail.

      My conversion pieced together from other posts:

      Func _convertToDateTime($dtString) Local $newdt $newdt = StringRegExpReplace($dtString, "A(d{4})(d{2})(d{2})(d{2})(d{2})(d{2})(?:.*)","$1-$2-$3 $4:$5:$6") MsgBox(0,"Convert Results",$newdt) Return($newdt) EndFunc
      When I search using the converted datetime, it is as if the query ignored the datetime value and returns all values of the 2D array.

      $iRval = _SQL_GetTable2D(-1, "select * from dbo.AllpagesToday WHERE PageRecip = 'SERVER_OC1' OR PageRecip = 'SERVER_ONCALL' AND Date > '" & _convertToDateTime($tmpDate) & "' ORDER BY Date;", $aData, $iRows, $iColumns)
      Any suggestions? If more information is needed, let me know.
    • mdthanh
      By mdthanh
      Hi,

      I have completed a script to export data from MSSQL or MSACCESS to Excel
      Hope it useful for someone.

      Screenshot:


      Features:
      Support database: MSSQL, MSACCESS
      Export speed of MSSQL: arround 15 seconds for 700,000 records with more than 30 fields.

      Will support more databases on next time and allow to select existing tables/views if any.

      MDT,
      ExportToExcelV1.rar
    • Herb191
      By Herb191
      Okay so quite a while back I thought I saw a AutoIt script that converted a MSSQL database to a MySQL database. I can’t seem to find it on the forums anywhere. Does anyone know if one exists? And if there is not an Autoit solution where I can find a good free converter. Thanks.
×