i want to select data from csv file here is my code
var filenamecsv="D://Data.csv";
adoConn1.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\;
Extended Properties='text;HDR=Yes;FMT=Delimited';");
adoRS1.Open("Select * From Data.csv",adoConn1,1,3);
but when i execute my project i get following error
Microsoft JET Database Engine: The Microsoft Jet database engine could not find the
object 'Data.csv'. Make sure the object exists and that you spell its name
and the path name correctly.
what should i do?
It could be that you need to escape your backslash in D:\ in the connection string and use Data Source=D:\\;
Rather than "D://Data.csv", try "D:\data.csv".
See here: http://www.connectionstrings.com/textfile for a useful reference.
Related
I'm new on Laravel
and I search for a way to run queries
I'm not talking about select etc...
I want to run this query:
SET NAMES 'utf8'
This is question number one,
Now question number two:
I have data writen in hebrew in my db
and when I do on Laravel this code:
$todolist = DB::select('select * from todo');
return $todolist;
I get this result:
[{"id":1,"name":"\u05d1\u05dc\u05d4 \u05d1\u05dc\u05d4 \u05d1\u05dc\u05d4","done":0},{"id":2,"name":"\u05d1\u05dc\u05d4 \u05d1\u05dc\u05d4 \u05d1\u05dc\u05d4","done":1}]
What is this? unicode? how can I turn it to hebrew again?
My mission is to send it back to client side and then show it on the web page
How can I translate this from unicode to hebrew with Java Script ?
You can use the statement method of the DB class, like so:
DB::statement("SET NAMES 'utf8'");
I'm not entirely aware of the situation but I would recommend this be within a migration.
Regarding the unicode characters, those should render in views correctly and should be usable within Javascript (see http://codepen.io/anon/pen/LZpOqY)
I'm using Play Framework and I have a .java Controller file in which I obtain an array of strings. I want to pass this Java array into an html file that will use Javascript in order to plot the data using Flot Charts. This data "transfer" is done in the render. It is something like this:
String[] array = new String[list.size()];
int i = 0;
for (Sample sample : list) {
array[i++] = sample.getContent();
}
render(array);
But then when I'm unable to call this variable in the .html file inside the views folder. If I use ${array}, Firebug tells me that it does not recognize it as a valid JS String array. I've read that Rhino or Nashorn could do the trick, but I do not know if they are the best and simplest option. Any ideas? Thanks!
I'm not familiar with Play Framework but I'm doing similar stuff using SparkJava in both java and javascript (using Nashorn).
I would suggest to use Boon library to generate json: https://github.com/boonproject/boon.
Here's a small Nashorn snippet to get you up to speed, easily adaptable to java:
// 1st we create a factory to serialize json out
var jso = new org.boon.json.JsonSerializerFactory().create();
// 2nd we directly use boon on array variable. Boon supports out of the box many pure java objects
jso.serialize(o);
In your specific case, you'll need to configure Play output for that particular render as application/json and possibly use render(jso.serialize(o)); in place of the small snippet I gave.
Using TestComplete's javascript engine to create a TADOConnection to a remote Oracle 11.2.0.3 server.
The query is a simple select with some basic where clauses:
Select * FROM MyUser.MyTable WHERE MyName = 'NAME' AND MyId like '1111%'
When executing the command, it fails and hits an exception with the helpful message of "Unspecified Error"
The odd part to this: Several other selects, deletes, inserts... work just fine using all the same connection logic. The same query even works if I change the * to the column names instead:
Select MyCol1, MyCol2, MyCol3 FROM MyUser.MyTable WHERE MyName = 'NAME' AND MyId like '1111%'
While this is a workaround, the tables have a very large number of Columns and I'd like the * to work as intended. Any ideas what may be causing the query to fail?
Also, running the query from sqlcmd and sqldeveloper both behave and return proper results.
This means that the table contains one or more fields with data type which is not supported by the OLE DB provider you use. To find out which exactly fields are problematic, you can add fields one by one to the query and check whether it works. Once you found the problematic fields, you will have to list all fields except for these in your Select clause.
Also, if you are using a provider from Microsoft (provider=MSDAORA), try changing it to the Oracle native provider (provider=OraOLEDB.Oracle).
I have data in a standalone Neo4j REST server, including an index of nodes. I want pure JavaScript client to connect to Neo4j and serve the formatted data to d3.js, a visualisation library built on Node.js.
JugglingDB is very popular, but the Neo4j implementation was done "wrong": https://github.com/1602/jugglingdb/issues/56
The next most popular option on github is: https://github.com/thingdom/node-neo4j
looking at the method definitions https://github.com/thingdom/node-neo4j/blob/develop/lib/GraphDatabase._coffee
I'm able to use "getNodeById: (id, _) ->"
> node1 = db.getNodeById(12, callback);
returns the output from the REST server, including node properties. Awesome.
I can't figure out how to use "getIndexedNodes: (index, property, value, _) ->"
> indexedNodes = db.getIndexedNodes:(index1, username, Homer, callback);
...
indexedNodes don't get defined. I've tried a few different combinations. No joy. How do I use this command?
Also, getIndexedNodes() requires a key-value pair. Is there any way to get all, or a subset of the items in the index without looping?
One of the authors/maintainers of node-neo4j here. =)
indexedNodes don't get defined. I've tried a few different combinations. No joy. How do I use this command?
Your example seems to have some syntax errors. Are index1, username and Homer variables defined elsewhere? Assuming not, i.e. assuming those are the actual index name, property name and value, they need to be quoted as string literals, e.g. 'index1', 'username' and 'Homer'. But you also have a colon right before the opening parenthesis that shouldn't be there. (That's what's causing the Node.js REPL to not understand your command.)
Then, note that indexedNodes should be undefined -- getIndexedNodes(), like most Node.js APIs, is asynchronous, so its return value is undefined. Hence the callback parameter.
You can see an example of how getIndexedNodes() is used in the sample node-neo4j-template app the README references:
https://github.com/aseemk/node-neo4j-template/blob/2012-03-01/models/user.js#L149-L160
Also, getIndexedNodes() requires a key-value pair. Is there any way to get all, or a subset of the items in the index without looping?
getIndexedNodes() does return all matching nodes, so there's no looping required. Getting a subset isn't supported by Neo4j's REST API directly, but you can achieve the result with Cypher.
E.g. to return the 6th-15th user (assuming they have a type property set to user) sorted alphabetically by username:
db.query([
'START node=node:index1(type="user")',
'RETURN node ORDER BY node.username',
'SKIP 5 LIMIT 10'
].join('\n'), callback);
Cypher is still rapidly evolving, though, so be sure to reference the documentation that matches the Neo4j version you're using.
As mentioned above, in general, take a look at the sample node-neo4j-template app. It covers a breadth of features that the library exposes and that a typical app would need.
Hope this helps. =)
Neo4j 2 lets you do indices VIA REST. Docs here
REST Indicies
I am writing a function that will sit in a external file that creates tables within a web DB. This is all being done with Javascript and HTML 5 local databases. I want to pass in a variable to generate the table name like:
mydb.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS **?** (id INTEGER PRIMARY KEY, name TEXT)', [**DB_Table**]);
});
but understand that the question mark can only be used in place of literals is there any way around this?
No, there is no way to parameterise schema names. If you really need to allow dynamic names, you will have to encode them into a schema name literal manually.
The ANSI SQL format for schema name literals is to surround them in double-quotes, and replace any double-quote character inside the string with a doubled double-quote.
var txlit= '"'+tc.replace(/"/g, '""')+'"';
query= 'CREATE TABLE IF NOT EXISTS '+txlit+' (id INTEGER ...)';
Well, there are some reasons for the limits of sql parameters.
But I think you are facing the meta programming issue, so check out the StringTemplate.
With StringTemplate, it dons't force you to use it exclusively. It just a String template language for any purpose.
Unfortunately, StringTemplate don't support JavaScript, but I think that the philosophy of it's design is still worth to know.