specify password in SQL

S

SomSallyX

Hi

I have 2 databases and both of them have identical table (i.e., same
structure) and also both are PASSWORD PROTECTED.
I have to insert records from one table (database #1) to another table
(database #2)

i tried the following SQL

insert into my_table in 'C:\DB1.mdb' select * from my_table

i'm getting an error "NOT A VALID PASSWORD". Is there any way in which i
can specify the password in the insert statement.


Warm Regards
 
B

Brendan Reynolds

I can't find anything in the help file, the KB or the MSDN library about
specifying a database password using the IN clause, so unless someone else
knows differently, it would appear that it can't be done. You can, of
course, link the table, or use DAO or ADO. See the following KB article for
the DAO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;209953

.... and this KB article for the ADO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;191754

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
S

SomSallyX

Even i thought about the same. Currently i follow the same logic. i.e.,
linking -> updating -> removing link.

Anyway just curious to know if it is possible at all to insert records by
using INSERT INTO from a external database, which would be faster and
reliable ? Lnking and updating or INSERT INTO from an external database?


Regards
 
6

'69 Camaro

Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid writing the
VBA involved in using the DAO or ADO methods and just run your SQL statement
directly from the query window, then create a new query and copy/paste the
following SQL statement into the SQL View pane (substitute your own password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword] SELECT *
FROM my_table;

.... then execute your query.

Note that Access will translate this into Jet SQL when you save it, so the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get into the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using the DAO
or ADO methods instead, and then compile the database into an MDE file so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled into a
new MDE as the need arises.

HTH.
Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.
 
B

Brendan Reynolds

Thanks, Gunny, I learned something new today.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


'69 Camaro said:
Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid writing the
VBA involved in using the DAO or ADO methods and just run your SQL statement
directly from the query window, then create a new query and copy/paste the
following SQL statement into the SQL View pane (substitute your own password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword] SELECT *
FROM my_table;

... then execute your query.

Note that Access will translate this into Jet SQL when you save it, so the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get into the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using the DAO
or ADO methods instead, and then compile the database into an MDE file so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled into a
new MDE as the need arises.

HTH.
Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


Brendan Reynolds said:
I can't find anything in the help file, the KB or the MSDN library about
specifying a database password using the IN clause, so unless someone else
knows differently, it would appear that it can't be done. You can, of
course, link the table, or use DAO or ADO. See the following KB article for
the DAO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;209953

... and this KB article for the ADO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;191754

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
which
 
S

SomSallyX

Thank you very gunny, it works!

similarly is it possible to update records in the same way. i.e., from a
diff database table (password protected)


regards

'69 Camaro said:
Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid writing the
VBA involved in using the DAO or ADO methods and just run your SQL statement
directly from the query window, then create a new query and copy/paste the
following SQL statement into the SQL View pane (substitute your own password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword] SELECT *
FROM my_table;

... then execute your query.

Note that Access will translate this into Jet SQL when you save it, so the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get into the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using the DAO
or ADO methods instead, and then compile the database into an MDE file so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled into a
new MDE as the need arises.

HTH.
Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


Brendan Reynolds said:
I can't find anything in the help file, the KB or the MSDN library about
specifying a database password using the IN clause, so unless someone else
knows differently, it would appear that it can't be done. You can, of
course, link the table, or use DAO or ADO. See the following KB article for
the DAO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;209953

... and this KB article for the ADO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;191754

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
which
 
S

SomSallyX

Yes. that's what i wanted.

Thanks again for that. This too worked.


Regards


'69 Camaro said:
You're welcome.

If I understand your question correctly, then yes. You can use the same
method to update records in a table in a database that has a database
password, using values from a different table. For example:

UPDATE my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
SET myField = 'myValue'
WHERE anotherField =
(SELECT someField
FROM diffTable
WHERE criteriaField = 10);

. . . where "my_table" is a table in the remote database, which contains
"myField" and "anotherField" fields, and "diffTable" is a table in the
current database, which contains "someField" and "criteriaField." Of
course, the subquery in this example can only return one record.

Or if "my_table" is in the current database and "diffTable" is in the remote
(password-protected) database, then this next example would work:

UPDATE my_table
SET myField = 'myValue'
WHERE anotherField =
(SELECT someField
FROM diffTable IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
WHERE criteriaField = 10);

Again, the subquery in this example can only return one record. Does this
answer your question?

Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


SomSallyX said:
Thank you very gunny, it works!

similarly is it possible to update records in the same way. i.e., from a
diff database table (password protected)


regards

'69 Camaro said:
Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid writing the
VBA involved in using the DAO or ADO methods and just run your SQL statement
directly from the query window, then create a new query and copy/paste the
following SQL statement into the SQL View pane (substitute your own password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
SELECT
*
FROM my_table;

... then execute your query.

Note that Access will translate this into Jet SQL when you save it, so the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get
into
the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using the DAO
or ADO methods instead, and then compile the database into an MDE file so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled
into
a someone
else impossible
for
with
 
6

'69 Camaro

You're welcome.

Brendan Reynolds said:
Thanks, Gunny, I learned something new today.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


'69 Camaro said:
Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid writing the
VBA involved in using the DAO or ADO methods and just run your SQL statement
directly from the query window, then create a new query and copy/paste the
following SQL statement into the SQL View pane (substitute your own password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword] SELECT *
FROM my_table;

... then execute your query.

Note that Access will translate this into Jet SQL when you save it, so the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get into the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using the DAO
or ADO methods instead, and then compile the database into an MDE file so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled into a
new MDE as the need arises.

HTH.
Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


Brendan Reynolds said:
I can't find anything in the help file, the KB or the MSDN library about
specifying a database password using the IN clause, so unless someone else
knows differently, it would appear that it can't be done. You can, of
course, link the table, or use DAO or ADO. See the following KB
article
for
the DAO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;209953

... and this KB article for the ADO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;191754

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Hi

I have 2 databases and both of them have identical table (i.e., same
structure) and also both are PASSWORD PROTECTED.
I have to insert records from one table (database #1) to another table
(database #2)

i tried the following SQL

insert into my_table in 'C:\DB1.mdb' select * from my_table

i'm getting an error "NOT A VALID PASSWORD". Is there any way in
which
i
can specify the password in the insert statement.


Warm Regards
 
6

'69 Camaro

You're welcome.

If I understand your question correctly, then yes. You can use the same
method to update records in a table in a database that has a database
password, using values from a different table. For example:

UPDATE my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
SET myField = 'myValue'
WHERE anotherField =
(SELECT someField
FROM diffTable
WHERE criteriaField = 10);

.. . . where "my_table" is a table in the remote database, which contains
"myField" and "anotherField" fields, and "diffTable" is a table in the
current database, which contains "someField" and "criteriaField." Of
course, the subquery in this example can only return one record.

Or if "my_table" is in the current database and "diffTable" is in the remote
(password-protected) database, then this next example would work:

UPDATE my_table
SET myField = 'myValue'
WHERE anotherField =
(SELECT someField
FROM diffTable IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
WHERE criteriaField = 10);

Again, the subquery in this example can only return one record. Does this
answer your question?

Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


SomSallyX said:
Thank you very gunny, it works!

similarly is it possible to update records in the same way. i.e., from a
diff database table (password protected)


regards

'69 Camaro said:
Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid writing the
VBA involved in using the DAO or ADO methods and just run your SQL statement
directly from the query window, then create a new query and copy/paste the
following SQL statement into the SQL View pane (substitute your own password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword] SELECT *
FROM my_table;

... then execute your query.

Note that Access will translate this into Jet SQL when you save it, so the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get into the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using the DAO
or ADO methods instead, and then compile the database into an MDE file so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled into a
new MDE as the need arises.

HTH.
Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


Brendan Reynolds said:
I can't find anything in the help file, the KB or the MSDN library about
specifying a database password using the IN clause, so unless someone else
knows differently, it would appear that it can't be done. You can, of
course, link the table, or use DAO or ADO. See the following KB
article
for
the DAO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;209953

... and this KB article for the ADO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;191754

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Hi

I have 2 databases and both of them have identical table (i.e., same
structure) and also both are PASSWORD PROTECTED.
I have to insert records from one table (database #1) to another table
(database #2)

i tried the following SQL

insert into my_table in 'C:\DB1.mdb' select * from my_table

i'm getting an error "NOT A VALID PASSWORD". Is there any way in
which
i
can specify the password in the insert statement.


Warm Regards
 
6

'69 Camaro

Glad to hear that the examples worked for you. You're very welcome.

Gunny

SomSallyX said:
Yes. that's what i wanted.

Thanks again for that. This too worked.


Regards


'69 Camaro said:
You're welcome.

If I understand your question correctly, then yes. You can use the same
method to update records in a table in a database that has a database
password, using values from a different table. For example:

UPDATE my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
SET myField = 'myValue'
WHERE anotherField =
(SELECT someField
FROM diffTable
WHERE criteriaField = 10);

. . . where "my_table" is a table in the remote database, which contains
"myField" and "anotherField" fields, and "diffTable" is a table in the
current database, which contains "someField" and "criteriaField." Of
course, the subquery in this example can only return one record.

Or if "my_table" is in the current database and "diffTable" is in the remote
(password-protected) database, then this next example would work:

UPDATE my_table
SET myField = 'myValue'
WHERE anotherField =
(SELECT someField
FROM diffTable IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
WHERE criteriaField = 10);

Again, the subquery in this example can only return one record. Does this
answer your question?

Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


SomSallyX said:
Thank you very gunny, it works!

similarly is it possible to update records in the same way. i.e., from a
diff database table (password protected)


regards

Yes. You can specify the database password in the IN clause of an INSERT
SQL statement in Microsoft Access. If you would rather avoid
writing
the
VBA involved in using the DAO or ADO methods and just run your SQL
statement
directly from the query window, then create a new query and
copy/paste
the
following SQL statement into the SQL View pane (substitute your own
password
for myPassword):

INSERT INTO my_table IN '' [;DATABASE=C:\DB1.mdb;PWD=myPassword]
SELECT
*
FROM my_table;

... then execute your query.

Note that Access will translate this into Jet SQL when you save it,
so
the
saved query will use the following syntax, which doesn't include the IN
clause:

INSERT INTO [;DATABASE=C:\DB1.mdb;PWD=mypassword].my_table
SELECT *
FROM my_table;

Of course, your database password will be visible in the destination
connection string property of your query for everyone to read, so this
isn't
a very secure way to do it. In your case, it sounds like both databases
have the same password. If this is correct, then those who can get into
the
first database already know the password for the second database, so this
doesn't pose an issue.

But for others who might use this method under typical conditions, I
recommend that they write VBA code for the query in a module using
the
DAO
or ADO methods instead, and then compile the database into an MDE
file
so
that the source code, including the database password for the remote
database, is hidden from view. And the original MDB file should be kept
available so that changes can be made in the future and recompiled
into
a
new MDE as the need arises.

HTH.
Gunny

See www.QBuilt.com for all your database needs.
See www.Access.QBuilt.com for Microsoft Access tips.


"Brendan Reynolds" <brenreyn at indigo dot ie> wrote in message
I can't find anything in the help file, the KB or the MSDN library about
specifying a database password using the IN clause, so unless someone
else
knows differently, it would appear that it can't be done. You can, of
course, link the table, or use DAO or ADO. See the following KB article
for
the DAO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;209953

... and this KB article for the ADO method ...

http://support.microsoft.com/default.aspx?scid=kb;en-us;191754

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible
for
me to use a real e-mail address in public newsgroups. E-mail
replies
to
this post will be deleted without being read. Any e-mail claiming
to
be
from brenreyn at indigo dot ie that is not digitally signed by me
with
a
GlobalSign digital certificate is a forgery and should be deleted
without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Hi

I have 2 databases and both of them have identical table (i.e., same
structure) and also both are PASSWORD PROTECTED.
I have to insert records from one table (database #1) to another table
(database #2)

i tried the following SQL

insert into my_table in 'C:\DB1.mdb' select * from my_table

i'm getting an error "NOT A VALID PASSWORD". Is there any way in
which
i
can specify the password in the insert statement.


Warm Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top