Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help with database connection - urgent


Hi

i got this code from a web site and its working, i just need to inser
the password of my database and i really don't know where it shoul
go.

Anyone could help?


Written : 23-May-2003 by Andy Wiggins - Byg Software Ltd

Function DbSource()
DbSource = ThisWorkbook.Path & "/bdalunosindex.mdb"
End Function

Function DbConnection()
DbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=
& DbSource & ";"
End Function

Sub SelectAndReturnRecordsADO()
Dim cnn As ADODB.Connection
Dim rstRecordset As ADODB.Recordset
Dim cmdCommand As ADODB.Command
Dim numberOfRows
Dim vtSql
Dim c As Field

'' Open the connection.
Set cnn = New ADODB.Connection
cnn.Open DbConnection

'' Set the command text.


Set cmdCommand = New ADODB.Command
Set cmdCommand.ActiveConnection = cnn



vtSql = " SELECT * FROM Pagamento ORDER BY Pagamento.c_Contrato"

With cmdCommand
.CommandText = vtSql
.CommandType = adCmdText
.Execute
End With

'' Open the recordset.
Set rstRecordset = New ADODB.Recordset
Set rstRecordset.ActiveConnection = cnn
rstRecordset.Open cmdCommand
rstRecordset.MoveFirs

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default help with database connection - urgent

joao

Use Data - Get External Data to create a new QueryTable in a new workbook
using the same database. Then, in the immediate window, type

?Sheet1.QueryTables(1).Connection

to get the propert connection string for that query. Dump the ODBC part at
the start and that's what you should use for your DbConnection variable.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"joao" wrote in message
...

Hi

i got this code from a web site and its working, i just need to insert
the password of my database and i really don't know where it should
go.

Anyone could help?


Written : 23-May-2003 by Andy Wiggins - Byg Software Ltd

Function DbSource()
DbSource = ThisWorkbook.Path & "/bdalunosindex.mdb"
End Function

Function DbConnection()
DbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source="
& DbSource & ";"
End Function

Sub SelectAndReturnRecordsADO()
Dim cnn As ADODB.Connection
Dim rstRecordset As ADODB.Recordset
Dim cmdCommand As ADODB.Command
Dim numberOfRows
Dim vtSql
Dim c As Field

'' Open the connection.
Set cnn = New ADODB.Connection
cnn.Open DbConnection

'' Set the command text.


Set cmdCommand = New ADODB.Command
Set cmdCommand.ActiveConnection = cnn



vtSql = " SELECT * FROM Pagamento ORDER BY Pagamento.c_Contrato"

With cmdCommand
CommandText = vtSql
CommandType = adCmdText
Execute
End With

'' Open the recordset.
Set rstRecordset = New ADODB.Recordset
Set rstRecordset.ActiveConnection = cnn
rstRecordset.Open cmdCommand
rstRecordset.MoveFirst


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default help with database connection - urgent

Try this link (all on one line):

http://www.able-consulting.com/MDAC/...orMicrosoftJet

It has demo connection strings for standard security, Workgroup
security, .MDB password, etc.

joao wrote in message ...
Hi

i got this code from a web site and its working, i just need to insert
the password of my database and i really don't know where it should
go.

Anyone could help?


Written : 23-May-2003 by Andy Wiggins - Byg Software Ltd

Function DbSource()
DbSource = ThisWorkbook.Path & "/bdalunosindex.mdb"
End Function

Function DbConnection()
DbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source="
& DbSource & ";"
End Function

Sub SelectAndReturnRecordsADO()
Dim cnn As ADODB.Connection
Dim rstRecordset As ADODB.Recordset
Dim cmdCommand As ADODB.Command
Dim numberOfRows
Dim vtSql
Dim c As Field

'' Open the connection.
Set cnn = New ADODB.Connection
cnn.Open DbConnection

'' Set the command text.


Set cmdCommand = New ADODB.Command
Set cmdCommand.ActiveConnection = cnn



vtSql = " SELECT * FROM Pagamento ORDER BY Pagamento.c_Contrato"

With cmdCommand
.CommandText = vtSql
.CommandType = adCmdText
.Execute
End With

'' Open the recordset.
Set rstRecordset = New ADODB.Recordset
Set rstRecordset.ActiveConnection = cnn
rstRecordset.Open cmdCommand
rstRecordset.MoveFirst


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help with database connection - urgent


Hi,

TYhanks for your help, but it isnt working for me. I tried the link an
the two options but it now returns another error message (before wa
invalid password) now it says something about my workgroup and someon
that have opened the database in exclusive mode.

any other idea

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default help with database connection - urgent

joao

What connection string did you get with the query table? What connection
string are you using in your code?

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"joao" wrote in message
...

Hi,

TYhanks for your help, but it isnt working for me. I tried the link and
the two options but it now returns another error message (before was
invalid password) now it says something about my workgroup and someone
that have opened the database in exclusive mode.

any other idea?


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 6
Default help with database connection - urgent

Hi,

When you open the connection do somethin'like this:


cnn.Open "DSN=mydatabase", just to make it easy... add a the
"mydatabase" to the ODBC manager, there you can provide the username
and password...






(onedaywhen) wrote in message m...
Try this link (all on one line):

http://www.able-consulting.com/MDAC/...orMicrosoftJet

It has demo connection strings for standard security, Workgroup
security, .MDB password, etc.

joao wrote in message ...
Hi

i got this code from a web site and its working, i just need to insert
the password of my database and i really don't know where it should
go.

Anyone could help?


Written : 23-May-2003 by Andy Wiggins - Byg Software Ltd

Function DbSource()
DbSource = ThisWorkbook.Path & "/bdalunosindex.mdb"
End Function

Function DbConnection()
DbConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source="
& DbSource & ";"
End Function

Sub SelectAndReturnRecordsADO()
Dim cnn As ADODB.Connection
Dim rstRecordset As ADODB.Recordset
Dim cmdCommand As ADODB.Command
Dim numberOfRows
Dim vtSql
Dim c As Field

'' Open the connection.
Set cnn = New ADODB.Connection
cnn.Open DbConnection

'' Set the command text.


Set cmdCommand = New ADODB.Command
Set cmdCommand.ActiveConnection = cnn



vtSql = " SELECT * FROM Pagamento ORDER BY Pagamento.c_Contrato"

With cmdCommand
.CommandText = vtSql
.CommandType = adCmdText
.Execute
End With

'' Open the recordset.
Set rstRecordset = New ADODB.Recordset
Set rstRecordset.ActiveConnection = cnn
rstRecordset.Open cmdCommand
rstRecordset.MoveFirst


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel connection to ODBC database Poppe Excel Discussion (Misc queries) 8 April 24th 09 06:16 AM
Serial Letter- Connection with Excel database Vic1978 Excel Discussion (Misc queries) 1 December 13th 05 02:07 PM
urgent: no connection to excel envisys Excel Programming 0 October 31st 03 08:40 AM
Does destroying the ADO Connection close the database? Bob Phillips[_5_] Excel Programming 0 July 18th 03 08:04 PM
Does destroying the ADO Connection close the database? Richard Choate Excel Programming 0 July 18th 03 07:45 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"