I have been searching for several hours regarding how to create a user using SQL for a database I am building in Access. I found several sources on Microsoft's website that say I can use the CREATE USER command to do this. However, whenever I attempt to run the query, an error saying Syntax error in CREATE TABLE statement pops up. What am I doing wrong? Thank you in advance for your help! If you're interested, the code format I am attempting to use is as follows: CREATE USER username, password, pid.
Access does support CREATE USER as a DDL statement, but unfortunately it won't work in all contexts. Specifically, it won't work if we try to run it from
the Query Designer within Access itself,
a DAO connection to the database, or
an ODBC connection to the database.
It will only work when run from an OLEDB connection to the database. That can be accomplished from VBA code within the Access database itself by using the CurrentProject.Connection object, like so:
CurrentProject.Connection.Execute _
"CREATE USER newuser newpassword newpid"
(Note that there are no commas between the three arguments to the CREATE USER statement.)
Related
I try to create a pretty complex database on ms Access 2013, so I wanted to type it directly in SQL. It has no errors, as other DBMS can fully build the database from the script I wrote (for example, phpmyadmin imports it with no difficulty).
On this tutorial, it is showed how to write a SQL query in order to build tables. I thought this way matched well with my goal as I could copy-paste my script in the query and run it to create the whole thing.
But when I tried to open/double-click on the query a pop-up appears saying "Select data source", waiting for me to select an ODBC, either from a file or a host, before continuing and executing the query.
I tried other types of queries (creating only one table at time, trying on a blank file, or even SELECT * FROM *), bt this message keeps showing up and I really don't know how to deal with it as I don't want to connect to anything but the infile database.
Does anyone got a hint about what to do in this case?
Or, even better, how could Access import my SQL script in order to create the database?
You should configure the database connection in the ODBC and check whether the connection is established or not. Once the connection is established, you can run the query to fetch the data or create tables as per your requirement.
I am calling oracle stored procedures via Pass Through Query in MS Access.
In pass through query properties we are saving connection string with password. I don't want to allow the user to see the password.
Is there any way to encrypt the password in pass through query.
Connection string contains
ODBC;DSN=NEW_ODBC;UID=XXXXX;PWD=XXXXXXX;DBQ=XXXXXX;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;BTD=F;BNF=F;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=F;CSR=F;FWC=F;FBS=64000;TLO=O;MLD=0;ODA=F;
I am using docmd to call the pass through query
DoCmd.OpenQuery "qry_into_table", acViewNormal, acEdit
If i remove the PWD from the above string, every time it ask for the password to enter. I heard about the concept to use DSN less connection but i am not sure how to create dsn less connection for odbc. I am using user dsn.
Is there any way to encrypt the password or user can not see the password??
Thanks
If you link all your tables and also that of pass-though queries and LEAVE OUT the uid/password, then your quires and linked tables etc. will run just fine. You need to execute JUST ONE logon command at application start.
So in your DSNless re-link code, include the pass-though queries.
How to eliminate the need to include the user id and password in linked tables it outlined here:
Power Tip: Improve the security of database connections
https://www.microsoft.com/en-us/microsoft-365/blog/2011/04/08/power-tip-improve-the-security-of-database-connections/
The above also works for pass-through queries.
The result is then you can execute the pass though query like this in code:
Currentdb.Execute "qry_into_table"
And you can even pass values to a stored procedure with this code:
With Currentdb.QueryDefs("MyPass")
.SQL = "exec sp_MyUpdate " & strParm1
.execute
End With
Note how clean, and how we don't have to deal with connection strings in code with the above.
So the above power tip really eliminates huge amounts of code, eliminates the need to introduce ADO for calling stored procedures, and removes the need of having to deal with messy connection strings in code.
I am trying to import a table from SQL into access but I am getting too many indexes in the table error. The table in SQL is indexed to several tables and unfortunately I don't have the rights to modify or change the table anyway. just have read access in the DB. I am trying to import/link the table but I am unable to do so due to too many indexes error being thrown.
Is it possible to only import/link the data and not indexes? I know access has a limit of 32 indexes. I have cleared auto indexes in options too, but I still get the error.
Is there a solution as to how I can import/link this table in access?
Thanks in advance
I did some digging on how to avoid this problem. So the problem is we can't directly link to the SQL database if the table has a lot of indexes and Access will throw an error "too many indexes on the table you are trying to import".
one way to beat this is by putting together a "Pass-through query". Lot of people suggested VBA code. I am not a coder and could not get it to work effectively. However, Access gives you the capability to build it with out VBA and the solution I found was in Microsoft website.
The steps are as follows: you might have to work around it for 2010 due to different naming convention when compared to 2007.
On the Create tab, click Query Design in the Other group.
Click Close in the Show Table dialog box without adding any tables or queries.
Save the query. Open the Query in design mode
On the Design tab, click Pass-Through in the Query Type workgroup.
Click Property Sheet in the Show/Hide workgroup to display the property sheet for the query.
In the query property sheet, place the mouse pointer in the ODBC Connect Str property, and then, click the Build (...) button.
With the ODBC Connect Str property, you specify information about the database to which you want to connect. You can type the connection information, or click Build, and then enter information about the server to which you are connecting.
When you are prompted to save the password in the connection string, click Yes if you want the password and logon name to be stored in the connection string information.
If the query is not the type that returns records, set the ReturnsRecords property to No.
In the SQL Pass-Through Query window, type your pass-through query. For example, the following pass-through query uses the Microsoft SQL Server TOP operator in the SELECT statement to return only the first 25 orders in the Orders table from the sample Northwind database:
SELECT TOP 25 orderid from orders
To run the query, click Run in the Results group on the Design tab. For a SQL pass-through query that returns records, click Datasheet view on the status bar.
If necessary, Microsoft Access prompts you for information about your server database.
This worked for me. If some one is having the same problem you can use these steps.
I can not retrieve data from db in sql server.
I use the c3p0 as the pool,this is the c3p0.properties:
c3p0.user=test
c3p0.password=123456
c3p0.jdbcUrl=jdbc:sqlserver://xxxxxx:1433;databaseName=TIMDB;SelectMethod=cursor
c3p0.driverClass=com.microsoft.sqlserver.jdbc.SQLServerDriver
c3p0.maxPoolSize=15
c3p0.testConnectionOnCheckin=true
c3p0.idleConnectionTestPeriod=3600
In the sql server,I have create a new user named test,and its default db is TIMDB,the server roles is public,and this is the user mapping:
But when I start the application,I can get nothing.
From the log created by log4j,I can get the sql used to retrieve data,but if I copy the sql to the sql management stutio and create a new query,I can retrieve some data.
I wonder why?
It looks like a permissions problem to me. If the generated SQl runs when you use it in management studio (i.e under your user account) then you know the code is good. What access have you given the user "test" from your post I see "user mapping: enter image description here"? he will need at least db_datareader and possibly more depending on what code is generated.
You could also try logging on to SQL Management studio under your "test" user and see if you can execute the code. That will eliminate the possibility that its something wrong with your application/network.
Need to query my SQL server from Access using an ADO connection (for example), and then using something like:
Currentdb.CreateTableDef()
in Access to create a table (in Access) with the query results.
How can I do this?
Using DAO:
currentdb.execute "SELECT * INTO LocalTableName FROM SQLServerTable;"
The string inside the quotes should be identical in ADO but I don't use ADO much.
You could consider SQL DDL CREATE TEMPORARY TABLE syntax. From the Access 2007 Help:
When a TEMPORARY table is created it
is visible only within the session in
which it was created. It is
automatically deleted when the session
is terminated. Temporary tables can be
accessed by more than one user.
... my tongue is firmly embedded in my cheek :) This syntax doesn't exist in the Access Database Engine and never has. Instead, it's another example of the appalling state of the Access documentation on the engine side of the house. Caveat emptor.