Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: OLEDB connection to SQL Server


Message #1 by "James Sharrett" <jsharrett@c...> on Thu, 2 May 2002 19:16:22
Well,
if you using some static data in your applet its better you download it
ahead.
If you need to use it in dynamic way and also some update functionality
you can create hidden frame and every time you need to make some update
just pass information to this page and execute it so you could create affect
of working against database client side.

Anyway, I don't have any experience with applet so its just a general idea
of how to do it.

Hope this is what you was looking for.

Oleg.

-----Original Message-----
From: James Sharrett [mailto:jsharrett@c...]
Sent: May 03, 2002 11:26 AM
To: javascript
Subject: [javascript] RE: OLEDB connection to SQL Server


Here is what I'm trying to do.  I have an applet on a page and I'm using
the API to run a function based on an event in the applet.  My function
changes some properties on the applet based on settings the user changes.
This all happens client side.  However, as part of my function I need to
query a table in a SQL Server database to determine what the properties
need to be set as.  The approach I was trying was to have two functions.
The main one generated from the API event would check for some values,
test to see if setting need to be updated.  If so, then I call the second
funtion and pass a parameter to it.  The second function (using runat 
server) takes the parameter and uses it as criteria to query the
database.  The results of the query (single value) are then used by the
main function to change the applet properties.

Is there an easier way to do this?  I have to use JavaScript for at least
the main function because the API requires it.


> I didn't meant in ASP I meant in JavaScript ,
since you posted it in JavaScript list.
I already saw people trying executing ASP code in JavaScript
so I didn't know if it is your case too.

Oleg.

-----Original Message-----
From: Joe Fawcett [mailto:joefawcett@h...]
Sent: May 03, 2002 2:47 AM
To: javascript
Subject: [javascript] RE: OLEDB connection to SQL Server


I find it hard to believe you never saw someone try to connect to a
database
in an ASP page.
Joe
----- Original Message -----
From: "Oleg Kapeljushnik" <c-oleg.kapeljushnik@w...>
To: "javascript" <javascript@p...>
Sent: Thursday, May 02, 2002 9:35 PM
Subject: [javascript] RE: OLEDB connection to SQL Server


> Are you using Client Javascript or Server Javascript ?
> if its server side then double check password and server name.
> You may use server ip instead of localhost like 127.0.0.1.
>
> If you doing it on client side. well..I never saw people doing it on
server
> side
> and as far as I know its not recommended at all.
>
> Oleg.
>
> -----Original Message-----
> From: James Sharrett [mailto:jsharrett@c...]
> Sent: May 02, 2002 5:12 PM
> To: javascript
> Subject: [javascript] RE: OLEDB connection to SQL Server
>
>
> OK...BIG duh on the typo.  I've been playing with this till I'm going
> blind.  I was using the variable sConnect to pass the string and then
just
> put the string in to try and get it working.  Obviously a little remedial
> pasting training required here.
>
> Changing (local) to be (localhost) did clear the real object error.
> However, now I'm getting a connection error message:
>
> [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or
access
> denied.
>
>
> Everything is on the local machine I'm running this on.  If I run is as
> VBScript as ASP it runs ok so I don't understand why it wouldn't connect
> when I run it in a javascript function.
>
> Thx,
> James
>
> > Try take out connection :
> sConnect = "Provider=SQLOLEDB;Data Source=(local);Initial
> Catalog=MYSCHEMA;User ID=MYUSER;Password=password"
> adoConnection.Open(sConnect);
>
> and also try change this
> Data Source=(local);
> to
> Data Source=localhost;
> or
> Data Source=127.0.0.1;
>
> this is in case SQL is installed on the same machine where you trying to
> execute your ASP pages.
>
> Oleg
>
> -----Original Message-----
> From: James Sharrett [mailto:jsharrett@c...]
> Sent: May 02, 2002 3:16 PM
> To: javascript
> Subject: [javascript] OLEDB connection to SQL Server
>
>
> Hi All,
>
> I'm trying to make a connection to a SQL Server database using an OLEDB
> provider and execute a query but I'm getting an object expected error.  I
> cannot tell if the problem is in the connection string.  Below is the
code:
>
> adoConnection = Server.CreateObject("ADODB.Connection");
> adoConnection.Open(sConnect = "Provider=SQLOLEDB;Data Source
> (local);Initial Catalog=MYSCHEMA;User ID=MYUSER;Password=password");
>
> adoRecordSet= adoConnection.Execute("Select Product from UnitProduct
where
> Unit = 'New York'");
>
> ProdName = adoRecordSet("Product").Value;
>
> alert (ProdName);
>
> adoConnection.Close();
> adoConnection=null;
>
> Where am I going wrong?
>
> Thx,
> James
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
>
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20
>
>
>
> ---
>
> Improve your web design skills with these new books from Glasshaus.
>
> Usable Web Menus
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
> http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
> http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20



---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


  Return to Index