1

Using MySQL & Java Script

I want to make a mysql connection in Java Script, then how can i get a table value by using this connection.

ASP.Net code

con.ConnectionString = "Dsn=server1;" + "Uid=root;" + "Pwd=root;"; con.Open();

cmd = new OdbcCommand("Select * from tb_values", con);
cmd.ExecuteNonQuery();

Above Code is working in asp.net, but i want to make a connection & select a values by using JavaScript.

Need JavaScript Code Help.

asked Jul 4, 2010 at 15:11
1
  • asp.net code executes on the server side, javascript executes on the client side. It is impossible to query the database on the server side from Javascript, unless you have something on the server side to accept queries and return JSON. Commented Jul 4, 2010 at 15:16

4 Answers 4

3

Above Code is working in asp.net, but i want to make a connection & select a values by using JavaScript.

That's not possible with javascript otherwise world would have seen your database connection code.

answered Jul 4, 2010 at 15:13
Sign up to request clarification or add additional context in comments.

Comments

1

Client side case:

The JS client side shouldn't be able to do that.

Server side case:

If you absolutely want to have JS on server side you might consider node.js, and a little google on "node js mysql".

answered Jul 4, 2010 at 15:19

Comments

0

With HTML5 you can create and query tables in the client side. Take a look at this post about HTML5 Web SQL database, you might find it useful depending on your case.

answered Jul 4, 2010 at 15:22

Comments

0

@sAc's answer is correct if you want to deploy this code for the public. However, if the database is local to that machine or is registered through an ODBC connection, you probably can access the DB using JavaScript (techinally, I guess this would be JScript). The pages would have to be run as HTAs, HTML Applications, a Microsoft-only sandbox system that removes virtually all restrictions you'd normally get with a web page on the Internet. You do have to change some of the ways you write your code and everything has to be run through ActiveX objects. If that's what you're after, check out Microsoft's documentation on the subject. HTAs are wicked fun to write, by the way.

answered Jul 4, 2010 at 16:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.