Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing an secured database with INSERT statement

Status
Not open for further replies.

lechuck

Programmer
Sep 4, 2000
26
SE
I'm working with a project of converting an application that use a access database to work against a SQL server 7.0 database.

Is it possible to access an password secured access database within the sql statement INSERT INTO?
I have tried without any luck....

Any better suggestion to insert data into a password secured DB?
 
If you're using ADO, ADODB.Connection.ConnectionString
is where you specify the dsn (if you are using one), the logon,
and the password for the database (the three are in quotes,
separated by semi-colons). Typically, you next issue the
ADODB.Connection.open statement.
You then specify the
command and commandtype in ADODB.Command.CommandText
and .CommandType, respectively, and issue the
ADODB.Command.Execute statement.

Example:

Set objCn = CreateObject("ADODB.Connection")
objCn.Errors.Clear

objCn.ConnectionString = "dsn=myDSN;UID=Admin" 'for db w/o password
objCn.Open

Set objCmd = CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objCn

With objCmd
.CommandText = strSQL 'which is already populated with the sql command
.CommandType = adCmdText
.Execute
End With

Set objCmd = Nothing
objCn.Close
Set objCn = Nothing


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top