473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can Connection ODBC Driver by Client JavaScript

Hello,
I wrote this code:
<%@ LANGUAGE=VBScript %>
<SCRIPT LANGUAGE=JavaScript>
function CustomerNameChange()
{
var forwarding_dbX;
var CustomerTableX;
set forwarding_dbX = Server.CreateObject("ADODB.Connection");
forwarding_dbX.Open "Forwarding";
set CustomerTableX= forwarding_dbX.Execute("SELECT * FROM CustomerTable
WHERE CustomerName='"&CustomerName.value&"'");
text153.value=CustomerTableX.Fields("Abbreviation" )
}
</SCRIPT>
<%
Dim forwarding_db
Set forwarding_db = Server.CreateObject("ADODB.Connection")
forwarding_db.Open "Forwarding"
Dim ForwardingTable
Dim CustomerTable
Set ForwardingTable = forwarding_db.Execute("SELECT * FROM Forwarding WHERE
ID =" & Request.QueryString("ID"))
Set CustomerTable= forwarding_db.Execute("SELECT * FROM Customer")
Response.Write "<SELECT id=CustomerName name=CustomerName
onchange=""CustomerNameChange()"">"
CustomerTable.Movefirst
Do until CustomerTable.EOF
Response.Write "<OPTION Value=" & CustomerTable.Fields("CustomerName")
if CustomerTable.Fields("CustomerName") =
ForwardingTable.Fields("CustomerName") then
Response.Write " Selected"
end if
Response.Write ">"
Response.Write CustomerTable.Fields("CustomerName")
Response.Write "</OPTION>"
CustomerTable.MoveNext
Loop
Response.Write "</SELECT>"
Response.Write "<INPUT type=""text"" id=text153 name=text153 >"
%>
But when change the CustomerName's SELECT,text153 can't shows
CustomerTableX.Fields("Abbreviation").I think in function
CustomerNameChange(),ODBC Driver not been connectioned.
Can you help me

Jul 19 '05 #1
7 18646
> set forwarding_dbX = Server.CreateObject("ADODB.Connection");

Sorry, this makes no sense. Client-side JavaScript cannot make an
ADODB.Connection to the server. You will need to submit to the server in
some way to make a new request from the database.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #2
Thank you for you advice.

I corrected the function
I wrote this code:

var forwarding_dbX;
var CustomerTableX;
forwarding_dbX = new ActiveXObject("ADODB.Connection");
forwarding_dbX.open("Forwarding");

But the final line is not correct.
Can you help me

Jul 19 '05 #3
Jack, you've been trying this for a couple of months now with mixing your
client side code and server-side code. How can we help you understand? The
server side code runs on the server and returns and html page to the
browser. When your page loads in a browser, do a view-source. Everything
that you see in that view-source is everything that the server does NOT see,
for all intents and purposes. It sees it, but it makes no attempt to do
anything with it other than to dump it off to the client machine that
requested the text. It doesn't matter if it says <script>function
whatever()</script>. If you see it in a view-source, to the server, it is
just a meaningless chunk of characters.

Now compare your view-source with your ASP source file. Everything that you
see in the source file that you do NOT see in your view-source is what the
server sees and actually processes and cares about.

Does this help at all or make any sense?
<SCRIPT LANGUAGE=JavaScript>
function CustomerNameChange()
{
var forwarding_dbX;
var CustomerTableX;
set forwarding_dbX = Server.CreateObject("ADODB.Connection");
forwarding_dbX.Open "Forwarding";
set CustomerTableX= forwarding_dbX.Execute("SELECT * FROM CustomerTable
WHERE CustomerName='"&CustomerName.value&"'");
text153.value=CustomerTableX.Fields("Abbreviation" )
}
</SCRIPT>

That is only seen by the browser. The server-side code has no idea what
"CustomerNameChange" is. As far as the server is concerned, that chunk of
text could be:

kja akjs dlkja8fajlk jfa
adfjkajd98f ali fadjf
ajdfaodsijfiad
fakdjfkja fd
ds98j4i
fjaijf
adf
It doesn't mean anything to the server. The user's browser is what will
know that function and be able to do something with it.

Ray at home

"Jack" <si*****************@yahoo.co.jp> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Thank you for you advice.

I corrected the function
I wrote this code:

var forwarding_dbX;
var CustomerTableX;
forwarding_dbX = new ActiveXObject("ADODB.Connection");
forwarding_dbX.open("Forwarding");

But the final line is not correct.
Can you help me

Jul 19 '05 #4
Aaron Bertrand - MVP wrote:
set forwarding_dbX = Server.CreateObject("ADODB.Connection");


Sorry, this makes no sense. Client-side JavaScript cannot make an
ADODB.Connection to the server. You will need to submit to the
server in some way to make a new request from the database.


Actually, it can, if the user has the proper security, and the database is
accessible, such as would be the case in an intranet application. I've
tested it and it does work.

The more over-riding question is: should you do it this way? Using ADO code
in client-side script means you have to make sure:

1. A working installation of MDAC exists on all the client machines, which
is not always the case (voice of experience here).
2. The database has to be accessible from all the client machines, either
via a network, or via installing the file-based database on the users'
machines <ugh!>
3. If you are using a DSN (definitely not recommended) or a UDL file (less
recommended, but at least it can use the native OLEDB provider for the
database), you will need to install the DSN or UDL file on all users'
machines.
4. The latest version of MDAC and IE include new security provisions to
prevent hacking. Some of these provisions will cause the user to receive
annoying warnings whenever the database is accessed
5. ... ummm - I've lost my train of thought (must be encroaching senility).
I had another point to make but it escapes me. I'm out of time anyways.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #5
Thank you!

Jul 19 '05 #6
> > Sorry, this makes no sense. Client-side JavaScript cannot make an
ADODB.Connection to the server. You will need to submit to the
server in some way to make a new request from the database.


Actually, it can, if the user has the proper security, and the database is
accessible, such as would be the case in an intranet application.


All right, touche'... allow me to rephrase... Client-side JavaScript has no
business making an ADODB.Connection to the server. Better? :-)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #7
Aaron Bertrand [MVP] wrote:
Sorry, this makes no sense. Client-side JavaScript cannot make an
ADODB.Connection to the server. You will need to submit to the
server in some way to make a new request from the database.


Actually, it can, if the user has the proper security, and the
database is accessible, such as would be the case in an intranet
application.


All right, touche'... allow me to rephrase... Client-side JavaScript
has no business making an ADODB.Connection to the server. Better?
:-)


:-)

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: SerGioGio | last post by:
Hello, I am going nuts. I am trying to connect to my local ORACLE instance using ODBC. It used to work few weeks ago, but it fails now. Connection with: - SQL*plus: connection works! -...
2
by: Dark_AvEnGer | last post by:
hey all, i want to create a client application to connect to a MySQL server on the internet so that multiple people may access the data from around the world. Is there a simple way to do this?...
4
by: Matthew Wells | last post by:
FIRST OF ALL, I APPRECIATE PEOPLE SENDIUNG ME LINKS TO WEB SITES FOR CONNECTION STRINGS BUT AS I'VE SAID BEFORE THAT IS NOT WHAT I NEED. I CAN EASILY OPEN AN ADO CONNECTION OBJECT TO AS400. I...
8
by: John Smith | last post by:
How do I connect to a FoxPro 7 database?
2
by: Ben | last post by:
Hi, I have a problem connecting to Oracle using and ODBC connection in a ASP.Net web page. The TNS Names works fine because when I create a DSN it works, and it works in SQL Plus. Here are...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
7
by: Bill Nguyen | last post by:
I have this connection string using ODBC DSN Dim FactorJaco As String = "dsn=jaco;catalog=factor;uid=user;pwd=passord" This requires an ODBC DSN (jaco) at every client PC. I need to use DSN-less...
3
by: zombiechewtoy | last post by:
I'm having trouble making an ODBC connection using VB.NET 2005. I have tried nearly every connection string found on connectionstrings.com, in almost every format I can think of. I have tried...
1
by: mikerudy | last post by:
I have an 3rd-party application that uses a SQL back-end, but uses Access 2000 (linked tables all using the same DSN) as an intermediary. We recently upgraded from SQL 7 to SQL 2005, which went...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.