Set Grant Permission to table in Access Database
Hello All,
How to set grant permission in Access 2003 Database. I am using Microsoft ACE OLEDB 12.0 Connection String, Using System.Data.OleDb Component and want to set Grant DELETE, INSERT, PROCEDURE, SELECT, UPDATE ON MSysObjects TO Admin
Best Regard
Xan To
Hello Kevin And Paul
I have tried what you all say, but I get an error like this
this my code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Builder As New OleDb.OleDbConnectionStringBuilder
Try
With Builder
.Provider = "Microsoft.ACE.OLEDB.12.0"
.DataSource = "C:\Users\Xan To\Desktop\Test.mdb"
End With
'Using cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Xan To\Desktop\Test.mdb; Jet OLEDB:System Database=system.mdw;")
Using cn As New OleDb.OleDbConnection
With cn
.ConnectionString = Builder.ConnectionString
End With
Using cmd As New OleDb.OleDbCommand
With cmd
.Connection = cn
.CommandText = "GRANT SELECT ON TABLE MSysObjects TO Admin"
End With
cn.Open()
cmd.ExecuteNonQuery()
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Similar Messages
-
How to grant permission to user to access Lync 2013 OcsPowerShell
I'm writing script for our first line for creating Lync users. I need give access to connect to https://lyncpool.domain.local/OcsPowerShell via powershell. Only users in CSAdministrator group have permission to connect, but this group have to much
privileges. I created custom group with custom permissions and I need grant permission to this group to access OcsPowerShell.Try giving them CsUserAdministrator RBAC membership. They should be able to run the following cmdlets to manage the users only:
Disable-CsUser
Enable-CsUser
Get-CsAdUser
Get-CsUser
Get-CsUserClusterInfo
Move-CsUser
Move-CsLegacyUser
Set-CsUser
Grant-CsClientPolicy
Grant-CsClientVersionPolicy
Grant-CsConferencingPolicy
Grant-CsDialPlan
Grant-CsExternalAccessPolicy
Grant-CsHostedVoicemailPolicy
Grant-CsLocationPolicy
Grant-CsPinPolicy
Grant-CsVoicePolicy
Get-CsArchivingPolicy
Get-CsClientPolicy
Get-CsClientVersionPolicy
Get-CsConferencingPolicy
Get-CsExternalAccessPolicy
Get-CsHostedVoicemailPolicy
Get-CsLocationPolicy
Get-CsPinPolicy
Get-CsVoicePolicy
Get-CsClientPinInfo
Unlock-CsClientPin
Lock-CsClientPin
Set-CsClientPin
Get-CsClientVersionConfiguration
Get-CsDialPlan
Get-CsSite
Get-CsComputer
Get-CsNetworkInterface
Get-CsPool
Get-CsService
Get-CsSipDomain
Revoke-CsClientCertificate
If this helped you please click "Vote As Helpful" if it answered your question please click "Mark As Answer" | Blog
www.lynced.com.au | Twitter
@imlynced -
How toplink grant permission for direct field access
I know already know that if I need to direct access private or protected field of an instance I must grant supressAccessChecks to ReflectPermission class using policytool or edit java.policy file directly ...
but how Toplink grant this permission to ReflectPermission class since my java.policy file remain the original.
Kowit LaisonIn my own experiences, the first release of JDK 1.2 had problems with reflection accessing private attributes. As you mentioned, you had to have a policy file that allowed TopLink access to reflectively access private attributes.
Since subsequent releases (1.2.x, 1.3, 1.4, etc), it always has "just worked". I.e., it seems to be default behavior of JVM's that you can acess private attributes through reflection. Sometimes some app servers come with startup scripts that have policies that change this default behavior and you have to override it, but in general, a vanilla JVM simply will allow private attribute access through reflection.
- Don -
Grant Permission In Access Database
Hello All
How to set Grant Permission in Access Database, I get an error here
what's wrong in my SQL syntax?
Best Regard
Xan ToHello Matthias Kläy
I Have try your code and I get an error
this my code
Imports System.Data.OleDb
Imports System.Data
Imports ADOX.ObjectTypeEnum
Imports ADOX.ActionEnum
Imports ADOX.RightsEnum
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cat As ADOX.Catalog
Dim grp As New ADOX.Group
Dim Builder As New OleDb.OleDbConnectionStringBuilder
Try
With Builder
.Provider = "Microsoft.ACE.OLEDB.12.0"
.DataSource = "C:\Users\Xan To\Desktop\Test.mdb"
End With
'Using cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Xan To\Desktop\Test.mdb; Jet OLEDB:System Database=system.mdw;")
Using cn As New OleDb.OleDbConnection
With cn
.ConnectionString = Builder.ConnectionString
End With
Using cmd As New OleDb.OleDbCommand
With cmd
.Connection = cn
.CommandText = "GRANT SELECT ON TABLE MSysObjects TO PUBLIC"
End With
cn.Open()
'cmd.ExecuteNonQuery()
cat = New ADOX.Catalog
cat.ActiveConnection = cn
grp.Name = "Public"
cat.Groups.Append(grp)
grp.SetPermissions("MSysObjects", adPermObjTable, adAccessGrant, adRightRead)
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class -
Can anyone help me here ?
I want to get the sql server table into access database .
I have tried below code from some Internet source but it didn't worked
Public Sub test1()
Dim conn As ADODB.Connection '<<<connection to SQL Server
Dim rst As ADODB.Recordset '<<<Recordset for SQL Server
Dim dbConn As ADODB.Connection '<<<connection for current access db
Dim sqlq As String
'create connection to external database
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & ServerName & ""
'On Error GoTo err
'Db.Open "Provider=SQLOLEDB.1;Data Source=" & ServerName & ";" & _
'Initial Catalog=" & DatabaseName & ";User ID=TestID;Password=srm"
'pull records from database into recordset
Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM Tbl_HRBPO_BAC_OMT_CS_Data "
Set dbConn = CurrentProject.Connection
'move through each record and load it into the local access database using Execute method
rst.MoveFirst
Do While Not rst.EOF
sqlq = "INSERT INTO newt VALUES('" & rst.Fields(0).Value & "', '" & rst.Fields(1).Value & "')"
dbConn.Execute sqlq
rst.MoveNext
Loop
dbConn.Close
Set dbConn = Nothing
rst.Close
conn.Close
Set rst = Nothing
Set conn = Nothing
End Sub
Thanks in advanceYou could use Export data in SMSS if it is a one time thing.
Andy Tauber
Data Architect
The Vancouver Clinic
Website | LinkedIn
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
"Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread. -
Crystal Reports and Access database connection error
I had this in a different forum with no hits, so I am trying this one.
A person that I work with has multiple reports set up that pulls from an Access database that is password protected. When we moved everything over to a new computer, those reports now say that it cannot access the fields inside the database. It never pops up with a login screen either, like it does on the old computer. I played around with the ODBC, with no luck, couldn't get anything to work. I have also tryed relinking the database, but I keep getting connection problems. We are on a network, so her settings should have all moved with the new computer. Along with the database and the reports being on the server, so they were never moved. I am thinking it has something to do with a system file.
I also found this document on this site, but cannot find the download it mentions, sounds similar to my problem.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/208b8fe5-681e-2b10-d2bb-b201f266d0ab
Does anybody know how to fix this without the utility mentioned in the above link, or know where I can get the utility??
We are using Access 2007 and Crystal Reports 7. The database is not save as an Access 2007 database, but a regular mdb.
Please Help!Post Author: ejthunder
CA Forum: Crystal Reports
Hello Chris,
Crystal Reports does not store the database password with the RPT file. This is by design (Crystal is not a database security product). This is true of all versions of Crystal Reports.
If your users need to see fresh data when opening the reports then they will have to log in by providing at least the password.
You can send reports with Saved Data that won't try to hit the database, but the data won't refresh either. To save data with the report go to the File menu and click next to Save Data with Report. Refresh the report and then save it. The report will now have saved data and won't try to hit the database when opened. If the user hits the refresh button then they will get prompted to log into the database.
I hope this helps.
EJ -
User Access to all tables of a database
Hi,
Is it possible to create a user that has access to all tables in a particular database? I know I can grant permissions on individual tables, but I would like to create a user that can add, delete, and insert data into any table in the database. This is easy in MSSQL, but not so easy with MaxDB
Thanks and Kind Regards,
Diana HoppeIt's not so easy, because it's a nonsense requirement!
While it may be convenient to be able to just access data and db-objects during development, this becomes a nightmare on production.
It's far easier and usually better to create schemas to put the database objects in and roles that have the required permissions.
Then you can grant the roles to the users that need them.
This way you've cleanly separated the naming (schemas) from the permission (roles/users/grants) aspect.
A common approach for this is:
- SYSDBA user (e.g. SUPERDBA) owns the application schemas and can create/alter the objects in it
- SYDBA also owns the roles and users.
One step more secure would be to have a specific user own the application schemas - just like it is the case for NetWeaver databases.
With this, you can have your DBAs have their superuser access to the database and still not the super-easy option to look at the data.
regards,
Lars -
Give user Read-Only access to one table in a database.
Does anyone know how to give a user account Read-only access to 1 table within a SQL Server Database using SQL Server Management Studio? I don't want the account to be able to access any other tables in the database, just the one table. I'm not a sql programmer,
so if there is a way to do it in Sql Server Managment Studio settings that would be the best.Using Management Studio, I assume you already have a login and user for that person. If not,
How to: Create a SQL Server Login http://msdn.microsoft.com/en-us/library/aa337562.aspx
How to: Create a Database User
http://msdn.microsoft.com/en-us/library/aa337545.aspx
1. Then, in Object Explorer, expand the Database, expand
Tables, right-click the table you want, and then click
Properties.
2. On the Permissions page, under Users or Roles, click
Search, then Browse, etc, until you find the user. Click
OK until you are back to the Permissions page.
3. In the Permission for <user>section, find the
SELECT (that's the read permission) and click the Grant
box. Then click OK.
Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty -
Getting the table names in an MS Access database
Hi,
I am new to JDBC and making a client/server application that updates a MS Access database through jdbc:odbc.
I need to get a list of existing user tables in the db. I have found a great document on the net which has the code, however the code doesn't work. I have tried different ways and looked every where with no success. (link to the doco: http://www-128.ibm.com/developerworks/opensource/library/j-jdbc-objects/)
Here is my dbManager class that handles all db related services in my application. I would appreciate any help I can get as I have exhusted all my avenues.
Thanks
Sep,
* dbManager.java
* Created on 31 October 2005, 10:20
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
import java.io.*;
import java.sql.*;
import java.util.regex.*;
* @author AUMahdavSe
public class dbManager {
/** Constant Declaration */
public static final String Driver = "sun.jdbc.odbc.JdbcOdbcDriver";
public static final
String sqlCreateTable = "create table TABLENAME (" +
"name varchar (100)," +
"surname varchar(100)," +
"computerType integer," +
"computerNAL varchar(20)," +
"haveMonitor integer," +
"monitorNAL varchar (20)," +
"auditDate varchar(10) );";
public static final String sqlUpdateTable = "insert into TABLENAME values" +
" (NAMEHOLDER, SURNAMEHOLDER, COMPTYPE, COMPNAL, HAVEMON, MONNAL);";
/** Attributes */
private String dbURL = "jdbc:odbc:";
private String Username = "admin"; // user input
private String Password = "purina123"; // user input
private String ODBCDataSource; // config file
private String dbPath; // set through config file or defaults to current folder
private String configFile = "config.txt"; // set either at commandline or defaults to current folder
private Connection con = null;
private Statement stmt = null;
private ResultSet tables;
private DatabaseMetaData dma;
private ResultSetMetaData rsmd;
private String CurrentAuditTable = "TestTable2";
int numCols, i;
/** Set Methodes */
public void setUsername( String usr ) {
this.Username = usr;
public void setPassword( String pswd ) {
this.Password = pswd;
public void setDbPath( String path ) {
this.dbPath = path;
public void setODBCDataSource( String ds ) {
this.ODBCDataSource = ds;
public void setDbURL( String dsname ) {
this.dbURL = this.dbURL + dsname;
/** Get Methodes */
public String getDriver() {
return this.Driver;
// can be run only after a connection obj is setup
public void getMDA() {
try {
this.dma = this.con.getMetaData();
catch (SQLException ex) {
System.err.println("database connection: " + ex.getMessage());
public void getDBTables() {
//now dump out the names of the tables in the database
String[] types = new String[1];
types[0] = "TABLES"; //set table type mask
//note the %-sign is a wild card (not '*')
try {
this.tables = this.dma.getTables(null, null, "%", types);
dumpResults("--Tables--");
this.tables.close();
//this.listTables();
catch (SQLException ex) {
System.err.println("database connection: " + ex.getMessage());
// listing tables
/*int count = 0;
int numCols = 0;
//ResultSetMetaData rsmd;
try {
System.out.println("Listing db tables ...");
//this.tables.beforeFirst();
rsmd = this.tables.getMetaData();
numCols = rsmd.getColumnCount();
System.out.println("number of cols: " + numCols);
boolean more = this.tables.first();
System.out.println("this is why: " + more);
while ( more ) {
count++;
for (int i = 1; i <= numCols; i++)
System.out.print( "Table-" + count + " -> " + this.tables.getString(count)+" " );
System.out.println();
more = this.tables.next();
catch ( SQLException ex ) {
System.out.println( "problem listing db tables: " + ex.getMessage() );
/** Other Methodes */
// Initialize the db parameters, like driver, username, passwd, etc.
public void dbInitialize() {
// load configuration from config.txt (dbPath and ODBC Data Source name)
this.loadDbConfig();
// loadDriver
this.loadDriver();
// get username and password for the ODBC from user
this.getDSSecurity();
// populate dbURL, username and password
this.setDbURL( this.ODBCDataSource );
// connect to db
this.dbConnect();
// get db metadata
this.getMDA();
// get a list of tables in db
this.getDBTables();
// load JDBC driver
public void loadDriver() {
try {
Class.forName( getDriver() );
} catch (Exception e) {
System.out.println("Failed to load JDBC/ODBC driver.");
return;
// connects to db and create a Connection obj and a Statement obj
public void dbConnect() {
try {
this.con = DriverManager.getConnection (
this.dbURL,
this.Username,
this.Password);
this.stmt = con.createStatement();
} catch (Exception e) {
System.err.println("problems connecting to "+this.dbURL);
// creates table tblname in db
public void CreateTable( String tblname ) {
try {
String sqlcommand = mergeTblName(sqlCreateTable, tblname);
this.stmt.execute( sqlcommand );
catch (SQLException ex) {
System.err.println("problems with SQL statement sent to "+this.dbURL+
": "+ex.getMessage());
System.out.println("SQL Command: " + mergeTblName(sqlCreateTable, tblname) );
// updates db with new record(s) by executing the SQL query sqlstmt
// and closes db connection
public void dbUpdate( String sqlstmt ) {
try {
// execute SQL commands to create table, insert data
this.stmt.execute( sqlstmt );
this.con.close();
} catch (Exception e) {
System.err.println("problems with SQL sent to "+this.dbURL+
": "+e.getMessage());
// list all user tables in the db
public void listTables() {
//now dump out the names of the tables in the database
int count = 0;
try {
System.out.println("Listing db tables ...");
//this.tables.beforeFirst();
while ( this.tables.next() ) {
count++;
System.out.print( "Table-" + count + " -> " + this.tables.getString(1) );
System.out.println();
catch ( SQLException ex ) {
System.out.println( "problem listing db tables: " + ex.getMessage() );
// checks whether tbname exist in db as a table
// this function has to be called after dbConnect
public boolean tableExists( String tbname ) {
boolean tbexists = false;
//get the database metadata
try {
dma = con.getMetaData();
catch (SQLException ex) {
System.err.println("database connection: " + ex.getMessage());
//now dump out the names of the tables in the database
String[] types = new String[1];
types[0] = "TABLES"; //set table type mask
//note the %-sign is a wild card (not '*')
try {
tables = dma.getTables(null, null, "%", types);
catch (SQLException ex) {
System.err.println("database connection: " + ex.getMessage());
try {
while ( tables.next() ) {
if ( tbname.equalsIgnoreCase( tables.getString(1) ) ) {
tbexists = true;
catch ( SQLException ex ) {
System.err.println("database connection: " + ex.getMessage());
return tbexists;
// merge tablename using REGEX
public String mergeTblName( String sqlcommand, String tbname ) {
String REGEX = "TABLENAME";
String INPUT = sqlcommand;
String REPLACE = tbname;
Pattern p = Pattern.compile(REGEX);
Matcher m = p.matcher(INPUT); // get a matcher object
INPUT = m.replaceAll(REPLACE);
//System.out.println(INPUT);
return INPUT;
// merge feildnames specific terms using REGEX
public String mergeFldName( Message msg ) {
String sqlcommand;
sqlcommand = "insert into TABLENAME values" +
" ('" + msg.getName() + "', '" + msg.getSurname() + "', " +
msg.getComputerType() + ", '" + msg.getComputerNAL() + "', " +
msg.getHaveMonitor() + ", '" + msg.getMonitorNAL() + "', '" +
msg.getDateOfMsg() + "');";
sqlcommand = mergeTblName( sqlcommand, CurrentAuditTable );
return sqlcommand;
// get users input char
/**public char getChar() {
int i = System.in.read();
while (i != -1) {
// here's your character
char c = (char) i;
i = System.in.read();
return (char) i;
// load the config parameters from config.txt
public void loadDbConfig() {
// make a file obj pointing to the config file config.txt
File configFile = new File( this.configFile );
//...checks on configFile are elided
StringBuffer contents = new StringBuffer();
//declared here only to make visible to finally clause
BufferedReader input = null;
try {
//use buffering
//this implementation reads one line at a time
input = new BufferedReader( new FileReader(configFile) );
String line = null; //not declared within while loop
int count = 0;
while (( line = input.readLine()) != null){
//first line in config file is dbPath
if(count == 0) this.setDbPath( line.trim() );
//second line in config file is ODBCDataSource
if(count == 1) this.setODBCDataSource( line.trim() );
count++;
//contents.append(line);
//contents.append(System.getProperty("line.separator"));
catch (FileNotFoundException ex) {
System.err.println("the file congif.txt cannot be found ...");
System.err.print("Enter the path to db file (e.g. c:\\temp): ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// read the db path from the command-line; need to use try/catch with the
// readLine() method
try {
this.setDbPath( br.readLine() );
catch (IOException ioe) {
System.out.println("IO error trying to read user input.");
System.exit(1);
System.err.print("Enter the name of the ODBC Data Source: ");
// read the ODBC Data Source name from the command-line; need to use try/catch with the
// readLine() method
try {
this.setODBCDataSource( br.readLine() );
catch (IOException ioe) {
System.out.println("IO error trying to read user input.");
System.exit(1);
ex.printStackTrace();
catch (IOException ex){
//ex.printStackTrace();
finally {
try {
if (input!= null) {
//flush and close both "input" and its underlying FileReader
input.close();
catch (IOException ex) {
//ex.printStackTrace();
//return contents.toString();
// get datasource security details i.e. username and password
public void getDSSecurity() {
// get username
System.out.print("Enter username for the ODBC DataSource: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// read the username from the command-line; need to use try/catch with the
// readLine() method
try {
this.setUsername( br.readLine() );
catch (IOException ioe) {
System.out.println("IO error trying to read username.");
System.exit(1);
// get password
System.out.print("Enter password: ");
// read the username from the command-line; need to use try/catch with the
// readLine() method
try {
this.setPassword( br.readLine() );
catch (IOException ioe) {
System.out.println("IO error trying to read password.");
System.exit(1);
private void dumpResults(String head)
//this is a general routine to print out
//column headers and the contents of each column
System.out.println(head);
try
//get the number of columns from the metadata
this.rsmd = this.tables.getMetaData();
numCols = this.rsmd.getColumnCount();
//print out the column names
for (i = 1; i<= numCols; i++)
System.out.print(rsmd.getColumnName(i)+" ");
System.out.println();
//print out the column contents
boolean more = this.tables.next();
while (more)
for (i = 1; i <= numCols; i++)
System.out.print(this.tables.getString(i)+" ");
System.out.println();
more = this.tables.next();
catch(Exception e)
{System.out.println(e.getMessage());}
/** Creates a new instance of dbManager */
public dbManager() {
this.dbInitialize();
}here is the result when I make a new dbManager obj from my server class which is a multithreaded one.
H:\java>java EchoServer
Enter username for the ODBC DataSource: admin
Enter password: purina123
Tables
TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS
Listening for clients on 12111...
here is the code of my server class called EchoServer:
import java.net.*;
import java.io.*;
public class EchoServer
ServerSocket m_ServerSocket;
dbManager haDB;
public EchoServer()
// db methods to setup a jdbc connection to the database
haDB = new dbManager();
// list tables
//haDB.listTables();
//haDB.getDBTables();
// create table
//haDB.CreateTable("TestTable2");
// update table
// server code
try
// Create the server socket.
m_ServerSocket = new ServerSocket(12111);
catch(IOException ioe)
System.out.println("Could not create server socket at 12111. Quitting.");
System.exit(-1);
System.out.println("Listening for clients on 12111...");
// Successfully created Server Socket. Now wait for connections.
int id = 0;
while(true)
try
// Accept incoming connections.
Socket clientSocket = m_ServerSocket.accept();
// accept() will block until a client connects to the server.
// If execution reaches this point, then it means that a client
// socket has been accepted.
// For each client, we will start a service thread to
// service the client requests. This is to demonstrate a
// multithreaded server, although not required for such a
// trivial application. Starting a thread also lets our
// EchoServer accept multiple connections simultaneously.
// Start a service thread
ClientServiceThread cliThread = new ClientServiceThread(clientSocket, id++, haDB);
cliThread.start();
catch(IOException ioe)
System.out.println("Exception encountered on accept. Ignoring. Stack Trace :");
ioe.printStackTrace();
public static void main (String[] args)
new EchoServer();
class ClientServiceThread extends Thread
Socket m_clientSocket;
int m_clientID = -1;
dbManager m_db;
boolean m_bRunThread = true;
ClientServiceThread(Socket s, int clientID, dbManager db)
m_clientSocket = s;
m_clientID = clientID;
m_db = db;
public void run()
// Obtain the input stream and the output stream for the socket
// A good practice is to encapsulate them with a BufferedReader
// and a PrintWriter as shown below.
BufferedReader in = null;
PrintWriter out = null;
Message msg = new Message();
// Print out details of this connection
System.out.println("Accepted Client : ID - " + m_clientID + " : Address - " +
m_clientSocket.getInetAddress().getHostName());
try
in = new BufferedReader(new InputStreamReader(m_clientSocket.getInputStream()));
out = new PrintWriter(new OutputStreamWriter(m_clientSocket.getOutputStream()));
// At this point, we can read for input and reply with appropriate output.
// Run in a loop until m_bRunThread is set to false
while(m_bRunThread)
// read incoming stream
String clientCommand = in.readLine();
if ( clientCommand.indexOf(",") != -1 ) {
msg.deserialize( clientCommand );
System.out.println("SQL command: " + m_db.mergeFldName(msg) );
m_db.dbUpdate( m_db.mergeFldName(msg) );
//System.out.println("Name :" + msg.getName() );
//System.out.println("Surname :" + msg.getSurname() );
//System.out.println("ComputerType :" + msg.getComputerType() );
//System.out.println("ComputerNAL :" + msg.getComputerNAL() );
//System.out.println("HaveMonitor :" + msg.getHaveMonitor() );
//System.out.println("Monitor NAL :" + msg.getMonitorNAL() );
//System.out.println("AuditDate :" + msg.getDateOfMsg() );
System.out.println("Client Says :" + clientCommand);
if(clientCommand.equalsIgnoreCase("quit"))
// Special command. Quit this thread
m_bRunThread = false;
System.out.print("Stopping client thread for client : " + m_clientID);
else
// Echo it back to the client.
out.println(clientCommand);
out.flush();
catch(Exception e)
e.printStackTrace();
finally
// Clean up
try
in.close();
out.close();
m_clientSocket.close();
System.out.println("...Stopped");
catch(IOException ioe)
ioe.printStackTrace();
}I find that taking any problem and reducing it to the simplest thing is the best way to approach it.
Why you had to post all that bloody code (especially since you didn't write it) is beyond me.
This will list all the tables in an Access database (or any other, for that matter):
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.jdom.Element;
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
public class TableLister
public static final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
public static final String DATABASE = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
public static final String USERNAME = "admin";
public static final String PASSWORD = "";
public static void main(String [] args)
try
String driver = ((args.length > 0) ? args[0] : DRIVER);
String url = ((args.length > 1) ? args[1] : DATABASE);
String username = ((args.length > 2) ? args[2] : USERNAME);
String password = ((args.length > 3) ? args[3] : PASSWORD);
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, username, password);
DatabaseMetaData meta = conn.getMetaData();
// Bring back ALL tables and views, including SYSTEM tables.
ResultSet tables = meta.getTables(null, null, null, null);
ResultSetMetaData rsmd = tables.getMetaData();
int numColumns = rsmd.getColumnCount();
List columnNames = new ArrayList();
for (int j = 0; j < numColumns; ++j)
columnNames.add(rsmd.getColumnName(j+1));
Element root = new Element("tables");
int tableCount = 0;
while (tables.next())
Element table = new Element("table");
table.setAttribute("id", Integer.toString(++tableCount));
for (int j = 0; j < numColumns; ++j)
Element column = new Element((String)columnNames.get(j));
column.setText(tables.getString((String)columnNames.get(j)));
table.addContent(column);
root.addContent(table);
conn.close();
Document doc = new Document(root);
XMLOutputter outputter = new XMLOutputter(" ", true);
System.out.println(outputter.outputString(doc));
catch (ClassNotFoundException e)
System.err.println("Couldn't load JDBC driver class");
e.printStackTrace();
catch (SQLException e)
System.err.println("SQL state: " + e.getSQLState());
System.err.println("SQL error: " + e.getErrorCode());
e.printStackTrace();
catch (Exception e)
e.printStackTrace();
}Run it and see if it works for you. If it does, put the essence of the code into your stuff.
% -
When I run the code below I get the following error:"RUN-TIME ERROR '3078': The Microsoft Access database engine cannot find the input table or query 'False'. Make sure it exists and that its name is spelled correctly. Note that I do not call
anything by the name of "false" anywhere in this code.
The subject code (the underscored line of code is highlighted in the debugger when the error occurs):
Option Compare Database
Private Sub JobAssign_Click()
MatLotListAvail_openform
End Sub
Function MatLotListAvail_openform()
Dim dbsAPIShopManager2010 As DAO.Database
Dim rstMaterialLotJobJoint As DAO.Recordset
Dim strSQL As String
Set dbsAPIShopManager2010 = CurrentDb
strSQL = "SELECT * FROM MaterialLotJobJoint WHERE JobID" = "tempvars!JobID" And "MatLotID" = "tempvars!MatLotID"
Set rstMaterialLotJobJoint = dbsAPIShopManager2010.OpenRecordset(strSQL, dbOpenDynaset)
If rstMaterialLotJobJoint.EOF Then
DoCmd.OpenForm "JobAssignMatConf", acNormal, "", "", acEdit, acNormal
Forms!JobAssignMatConf!PartapiIDVH = TempVars!PartapiID
Forms!JobAssignMatConf!JobapiIDVH = TempVars!JobapiID
Forms!JobAssignMatConf!JobIDVH = TempVars!JobID
Forms!JobAssignMatConf!MaterialLotIDVH = TempVars!MatLotID
Forms!JobAssignMatConf!Desc = TempVars!MatDesc
Forms!JobAssignMatConf!recdate = TempVars!recdate
DoCmd.Close acForm, "MaterialLotListAvailable"
Else: MsgBox "This material lot has already been assigned to this job."
DoCmd.Close acForm, "MaterialLotListAvailable"
End If
End FunctionI think the SQL statement should be
strSQL = "SELECT * FROM MaterialLotJobJoint WHERE JobID=" & _
tempvars!JobID & " AND MatLotID=" & tempvars!MatLotID
This assumes thatJobID and MatLotID are number fields.
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
How do I grant permission in privacy setting?
Ever since updating to iOS7, any apps that require permission in my privacy setting are not actually showing up under the privacy setting. For example, if I want to use Instagram, it won't access my photo albums. It says to grant permission under settings>privacy>photos. When I do that, there are no apps listed requesting permission to access my photos. Any ideas/suggestions? Thanks in advance!
I had a similar issue and to solve it I simply erased the app and redownloaded it and when it initally asks for permission in a pop up be sure to say yes.
I am sure there is a more technical solution for this issue but I have not been able to find one. Let me know how this works for you
Regards,
Jake -
I'm new to VS. I have run the following code. It does not produce any error, and it does not add or update data to my Access database table.
dbUpdate("UPDATE prgSettings SET varValue='test' WHERE varSetting='test'")
Function dbUpdate(ByVal _SQLupdate As String) As String
Dim OleConn As New OleDbConnection(My.Settings.DatabaseConnectionString.ToString)
Dim oleComm As OleDbCommand
Dim returnValue As Object
Dim sqlstring As String = _SQLupdate.ToString
Try
OleConn.Open()
MsgBox(OleConn.State.ToString)
oleComm = New OleDbCommand(sqlstring, OleConn)
returnValue = oleComm.ExecuteNonQuery()
Catch ex As Exception
' Error occurred while trying to execute reader
' send error message to console (change below line to customize error handling)
Console.WriteLine(ex.Message)
Return 0
End Try
MsgBox(returnValue)
Return returnValue
End Function
Any suggestions will be appreciated.
Thanks.You code looks pretty good, at a quick glance. Maybe you can simplify things a bit.
For Insert, please see these samples.
http://www.java2s.com/Code/CSharp/Database-ADO.net/Insert.htm
For Update, please see these samples.
http://www.java2s.com/Code/CSharp/Database-ADO.net/Update.htm
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.
Best to keep samples here to VB.NET
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
Need to grant permission to programme attempting to access firewall
Hi,
I want to allow a programme access my firewall but am having problems. This is the message in my firewall log.
Jan 29 22:50:23 bryan-collins-imac Firewall[50]: Deny Connect360Helper data in from 192.168.1.5:62626 uid = 0 proto=17
The Connect360 Helper is the programme I want to grant permission to but I can't find it in Spotlight. Any ideas?Hi Silvine,
I'd get EasyFind...
http://www.versiontracker.com/dyn/moreinfo/macosx/11706
You can also in the Sharing Pref Pane>Firewall tab>New...>Other, set Port 62626 to open UDP and/or TCP, and name it C360Helper or something. -
Error while accessing a Table on Oracle Database 10.2
Hi Experts,
We have a table that contains a CLOB datatype in one of its column. However when i tried to access the table i get the below error.
<b>Table Name:</b> discrete_jobs
<b>Error:</b>
(Error starting at line 1 in command:
select * from [email protected]
Error report:
SQL Error: ORA-22992: cannot use LOB locators selected from remote tables
22992. 00000 - "cannot use LOB locators selected from remote tables"
*Cause: A remote LOB column cannot be referenced.
*Action: Remove references to LOBs in remote tables.)
Pleas Help!
Regards,
Ravi RSee some work arounds - "How to select table from remote database having clob field</a>
-
How to automate creation of MS Access databases/tables/records
Can someone point me to some examples that automate the creation of MSAccess database files and tables?
Can I do this with a bat file? If not, a ps1 file?
I bing searched and could not find an example.
I want to test the existence of a mdb (or accdb) file and if it does not exist, create it.
Then I want to see if that mdb (or accdb) file contains a table named "parts".
If it does not contain that table named "parts", create the table.
If that table does not contain any records, than add some sample data, presumably with some SQL "INSERT" statements.
What is the preferred API for this? I was thinking we should use the ADO.NET/OleDB API. I did find a few examples of queries of MSAccess databases with the old ADO API.
ADOX seems very old for creating databases. Is there any thing more modern?
Is powershell the easiest scripting language to do this?
Thanks
Siegfried
siegfried heintzeThis blog post should have most (if not all) of what you need:
http://blogs.technet.com/b/heyscriptingguy/archive/2009/02/16/how-can-i-use-windows-powershell-to-create-an-office-access-database.aspx
One thing to watch out for is the db provider for the connection string. The "Jet Engine" has been superseded by
ACE.
Maybe you are looking for
-
Tax issue in third party order related intercompany billing
Hi, I have one isseu related to tax determination in third party order related billing document. Ordering sales organization : Germany Delivering sales organization: France In billing document the Delivering country: FR (France) Receiving Country: DE
-
Why is the video audio white noise when I share my project since I updated to 10.0.9
On the movies I created before I updated to 10.0.9, the audio prortion of the video is now white noise. The audio is fine when played back in FCP, but when i share the project it is white noise. When I burn it to BluRay the audio is gone all together
-
Captivate 4 export backgound images as jpeg
I am trying to use Captivate 4 in conjunction with another piece of software for creating web help files. I am using Captivate to create software demos for training purposes. As this will also generate the screenshots I need for my web help files, I
-
Web gallery with links to hires images - possible?
Hi all, I would like to use a web gallery to "deliver" hires images to clients, meaning that I want to have a preview page with thumnail images that should link to hires jpeg or even tif images for download. I found, however, that Aperture web galler
-
Looking for an iPad 2 case that holds notepad.
Hello, I am looking for an iPad 2 case that holds notepad. But I would like it thin. Not a big puffy leather case. anyone know of any? thanks