Perl connection SQL Server

zhaozj2021-02-16  44

Oh. I finally explored myself for a long time. Write out everyone sharing.

In fact, it is very simple. I have walked N and returned again.

Ready to work:

The useful Perl extension component is posted on the last. (Win32 :: ODBC module)

After downloading the component, follow the readme file to install the response directory. Configure the appropriate ODBC data source.

Program implementation:

use

Use Win32 :: ODBC;

The statement contains the module that should be used is Win32 :: ODBC

Write a database connection string

$ DSN = "DSN = My DSN; UID = SA; PWD = Password"

Then you can establish a corresponding connection

$ Data = New Win32 :: ODBC ($ DSN) # New A Connection Object

This creates the connection between SQL Server points to the data source.

Of course there is more more complex database operations. You can refer to the object description documentation.

Simple example:

$ Data-> TableList; # get a list of all basic tables of the database

$ data-> SQL ("Select * from [TableName]") # Execute a query statement

$ Data-> FieldNames (); # get a list of columns (attributes)

....

There are still many operations that have a detailed introduction in the documents given by the original block authors.

转载请注明原文地址:https://www.9cbs.com/read-27377.html

New Post(0)