Hello everyone
I'm starting to study team developer ... I have a question ... I have a form with a data field (name) and a button. In the sql server I have a database called test and a table named table1 with a column (names). I want when the user clicks the button, the system saves as a record in the sql server.
I also want to know a way to bring the sql server names field to my application.
thank you
Sql server
Re: Sql server
Hi.
I suggest to install samples. Installer is downloadable from OpentText- same place where u got TD.
In folder Samples\Connectivity\SQLServer u can find way to connect to sqlserver.
Another great place where u can find a lot of information is here:
https://wiki.tdcommunity.net/index.php?title=Main_Page and another samples
https://samples.tdcommunity.net/
To connect to sqlserver i suggest here another way- use udl:
You need to install SQLNativeClient: https://www.google.ee/search?q=sqlncli1 ... e&ie=UTF-8
Coding:
Set SqlDatabase=''
Set SqlUser=''
Set SqlPassword=''
Set SqlUDL='[oledb]
Provider=SQLNCLI11.1;Persist Security Info=False;User ID=USERNAME;Password=PASSWORD;Initial Catalog=DATABASE;Data Source=HOST;Trusted_Connection=No;MARS Connection=True;'
If NOT SqlConnect( hMSSql )
Set sError='Error:NO Connect'
Return FALSE
! and next do what u need to do:
If SqlPrepareAndExecute(hMSSql,'SELECT ... FROM ... WHERE ... INTO :.., ;.. ')
While SqlFetchNext(hMSSql,mA)
....
If SqlPrepareAndExecute(hMSSql,'INSERT INTO (...) VALUES (...)')
....
If SqlPrepareAndExecute(hMSSql,'UPDATE TBNAME SET ..., ... WHERE ...')
....
!And ofcouse - dont mis to commit/ rollback and disconnect asap.
Call SqlCommit( hMSSql )
Call SqlDisconnect(hMSSql )
Best regards,
Riho
I suggest to install samples. Installer is downloadable from OpentText- same place where u got TD.
In folder Samples\Connectivity\SQLServer u can find way to connect to sqlserver.
Another great place where u can find a lot of information is here:
https://wiki.tdcommunity.net/index.php?title=Main_Page and another samples
https://samples.tdcommunity.net/
To connect to sqlserver i suggest here another way- use udl:
You need to install SQLNativeClient: https://www.google.ee/search?q=sqlncli1 ... e&ie=UTF-8
Coding:
Set SqlDatabase=''
Set SqlUser=''
Set SqlPassword=''
Set SqlUDL='[oledb]
Provider=SQLNCLI11.1;Persist Security Info=False;User ID=USERNAME;Password=PASSWORD;Initial Catalog=DATABASE;Data Source=HOST;Trusted_Connection=No;MARS Connection=True;'
If NOT SqlConnect( hMSSql )
Set sError='Error:NO Connect'
Return FALSE
! and next do what u need to do:
If SqlPrepareAndExecute(hMSSql,'SELECT ... FROM ... WHERE ... INTO :.., ;.. ')
While SqlFetchNext(hMSSql,mA)
....
If SqlPrepareAndExecute(hMSSql,'INSERT INTO (...) VALUES (...)')
....
If SqlPrepareAndExecute(hMSSql,'UPDATE TBNAME SET ..., ... WHERE ...')
....
!And ofcouse - dont mis to commit/ rollback and disconnect asap.
Call SqlCommit( hMSSql )
Call SqlDisconnect(hMSSql )
Best regards,
Riho
-
- Site Admin
- Posts: 313
- Joined: 05 Mar 2017, 20:57
- Location: Tauranga, New Zealand <--> Stroud, England
Re: Sql server
For anyone reading this and considering the ODBC v OLE DB for SQLServer conundrum ..... wef April 2018, Microsoft have just 'undeprecated' their OLE DB Driver for SQL Server versions 2012 to 2017, and released a brand new OLE DB driver which will 'be developed further in preference to ODBC' .
I am testing right now against TD6 and TD7 - so far Ok.
The variable SqlUDL in place of SqlUser, SqlDatabase and SqlPassword can contain a .udl file name with the SqlServer connection string in it, or the string itself. A .udl file is easiest, just create a .txt file, rename it to .udl , double click the .udl file, and a connection wizard allows easy configuration.
So you don't need a Sql.ini or a DSN at all. So much easier to deploy.
Go here for details / download: https://blogs.msdn.microsoft.com/sqlnat ... ql-server/
I am testing right now against TD6 and TD7 - so far Ok.
The variable SqlUDL in place of SqlUser, SqlDatabase and SqlPassword can contain a .udl file name with the SqlServer connection string in it, or the string itself. A .udl file is easiest, just create a .txt file, rename it to .udl , double click the .udl file, and a connection wizard allows easy configuration.
So you don't need a Sql.ini or a DSN at all. So much easier to deploy.
Go here for details / download: https://blogs.msdn.microsoft.com/sqlnat ... ql-server/
Greetings from New Zealand
Steve Leighton
Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand
www.banksidesystems.co.uk

Steve Leighton
Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand
www.banksidesystems.co.uk

-
- Site Admin
- Posts: 313
- Joined: 05 Mar 2017, 20:57
- Location: Tauranga, New Zealand <--> Stroud, England
Re: Sql server
Attached is a simple TD63 app and .udl file to test connecting to a SQLServer 2017 database.
It just connects a handle then disconnects.
You need to edit the attached .udl file to your own environment by double clicking on it and selecting the 'All' tab to set the values to your own environment !
This .udl assumes Windows Authentication, so no User and Password, but change this in the .udl settings if you use SqlServer authentication .
You do not need any sql.ini or DSN. Only a SQLServer OLEDB driver which comes with Sql Server anyway.
ps you CANNOT edit the .udl via Notepad++ or any text editor I know of. It will crash in a heap. Only use the wizard by double clicking the .udl file .
It just connects a handle then disconnects.
You need to edit the attached .udl file to your own environment by double clicking on it and selecting the 'All' tab to set the values to your own environment !
This .udl assumes Windows Authentication, so no User and Password, but change this in the .udl settings if you use SqlServer authentication .
You do not need any sql.ini or DSN. Only a SQLServer OLEDB driver which comes with Sql Server anyway.
ps you CANNOT edit the .udl via Notepad++ or any text editor I know of. It will crash in a heap. Only use the wizard by double clicking the .udl file .
You do not have the required permissions to view the files attached to this post.
Greetings from New Zealand
Steve Leighton
Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand
www.banksidesystems.co.uk

Steve Leighton
Bankside Systems Ltd.
UK ♦ Australia ♦ New Zealand
www.banksidesystems.co.uk

Re: Sql server
We use ODBC and the sql.ini is essential only for the substitutes. Our packages need to run on Sqlbase also.
Who is online
Users browsing this forum: [Ccbot] and 0 guests