Home  >  Article  >  System Tutorial  >  How to connect to SQL database using LabWindows CVI

How to connect to SQL database using LabWindows CVI

WBOY
WBOYforward
2024-01-25 08:06:11656browse

labwindows cvi如何与SQL数据库连接

How to connect labwindows cvi to SQL database

1. Configure the data source in ODBC

2.ConnectHandle=DBConnect ("DSN=CVILocal;UID=sa;PWD=123");

ActivateHandle= DBActivateSQL (ConnectHandle, "select * from flag table");

while(DBFetchNext(ActivateHandle)==DB_SUCCESS)

{

DBGetColVariant (ActivateHandle, 2, &TempInt);

CA_VariantConvertToType (&TempInt, CAVT_INT, &StartMarkInt);

}

DBDeactivateSQL (ActivateHandle);

DBDisconnect (ConnectHandle);

How to connect sql by running access file

--In Access query, how to use SQL to access the table in SQL Server? Various ways: 1. Use linked tables. 2. Use pass query. 3. Just specify the connection information directly in the local query string, as follows: select*fromOrdersin[ODBC][ODBC;Driver=SQL Server;Server=.;Uid=sa;Pwd=0;database=Northwind]INSERTINTO target database table Name (field list) INODBC[ODBC;Driver=SQL Server;Server=server name or IP;Uid=sa;Pwd=password; database=database name]SELECT field list fromAccess local table

The working principles of transitive query and linked table are different: 1. Passive query: Write the SQL statement that needs to query local data in the transitive query. After execution, only the data that meets the query conditions will be returned. 2. Linked table: When opening a linked table, all data in the connected SQL Server table is returned.

To import data in the table, you need to create a DSN first. --Control Panel--Administrative Tools--Data Source (ODBC)--Select the file DSN page--Add--Select the last line: SQL Server--Specify the data source name, as long as it is easy to remember--Specify the one to be connected Server name or IP, this machine can use.--Select SQL Server hybrid authentication, enter the user and password--Change the default database to the database you want to connect--Complete--Then when creating the link table in your MDB, select This data source will do.

When using a link table, it is recommended to use a file data source to create the link table. It has nothing to do with the machine. You can copy it to another machine and use it directly. There is no need to create ODBC manually or with code.

Comparison of three data sources: File DSNODBC file data source allows users to connect to data providers. File DSNs can be shared by users who have the same driver installed.

How to use Access to connect to a remote SQL database

Take windowsxp Access2003 sqlserver2000 as an example:

1. Establish ODBC data source:

1. Open Control Panel\Management Tools

2. Running data source (ODBC)

3. Select the "User DSN" tab

4. Click the Add button, select SQL Server, and click Finish

5. Enter the name (mydbserver), select the server address, and click Next

6. Enter your account password and click Next

7. Click Next, continue and click Finish.

2. Establish Access remote data connection

1. Run Access and open or create a new mdb file

2. Click the "File" menu -> "Get External Data" -> "Linked Table"

3. In the link dialog box, select "ODBC Database ()" as the file type

4. Select data source pops up, click "Machine Data Source", and select the ODBC data source (mydbserver) just defined

5. Enter the sql server database account and password. Click the "Options" button, select data, and click OK.

6. Select the table you want to link and click OK.

7. Select the fields of the table you want to link and click OK.

----------------------

complete.

The above is the detailed content of How to connect to SQL database using LabWindows CVI. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:docexcel.net. If there is any infringement, please contact admin@php.cn delete