473,785 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wrong connection string to a sql-server


Hi,
on a simple HTML (not an ASP!)-Site I try to connect to a sql server
(MS):

<html>
<title>Test</title>
<head>
<script language="javas cript">
<!--
Function showForm(){
var conn
conn = CreateObject("A DODB.Connection ");
var rst
var = CreateObject("A DODB.recordset" );
var sql
sql = "select f01, f02 from IT_ASP where id < 10";
conn.Open "Provider=SQLOL EDB.1;Persist Security Info=False;User
ID=sa;Initial Catalog=Projekt ;Data Source=MYSERVER \MYSQL;pwd=123A bc.";
rst.Open (sql, conn);
while (!rst.EOF){
document.write( rst(0));
document.write( "<br>");
rst.MoveNext;
}
rst.Close;
rst=Nothing;
document.close;
}
//-->
</script>
</head>
<body>
<form name="myform" action="">
<input name="but1" type="button" value="klick"
onClick="javasc ript:showForm() ">
</form>
</body>
</html>

I'm still getting an error: object expected.
What's wrong? (I know, it's late...)
Andy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
6 23514
In article <3f************ ***********@new s.frii.net>,
aw*********@arc or.de says...

Hi,
on a simple HTML (not an ASP!)-Site I try to connect to a sql server
(MS):

Should
Function showForm(){
be
function showForm(){
--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php
Jul 20 '05 #2
In article <3f************ ***********@new s.frii.net>,
aw*********@arc or.de says...

Hi,
on a simple HTML (not an ASP!)-Site I try to connect to a sql server
(MS):

I'm still getting an error: object expected.
What's wrong? (I know, it's late...)


And you seem to be trying to run ASP code on the client. How do figure
that will work?

--
Hywel I do not eat quiche
http://hyweljenkins.co.uk/
http://hyweljenkins.co.uk/mfaq.php
Jul 20 '05 #3
"Andy Wawa" <aw*********@ar cor.de> wrote in message
news:3f******** *************** @news.frii.net. ..
on a simple HTML (not an ASP!)-Site I try to connect to
a sql server (MS):

<html>
<title>Test</title>
<head>
<script language="javas cript">
<!--
Function showForm(){
var conn
conn = CreateObject("A DODB.Connection ");
I think that CreateObject is VBScript not JavaScript.

<snip>conn.Open "Provider=SQLOL EDB.1;Persist Security Info=False;User
ID=sa;Initia l Catalog=Projekt ;Data Source=MYSERVER \MYSQL;pwd=123A bc.";

<snip>

If this is Internet I hope you have thought out the security
implications of sending this information to the client.

Richard.
Jul 20 '05 #4
Andy Wawa wrote:
Hi,
on a simple HTML (not an ASP!)-Site I try to connect to a sql server
(MS):

Do you want this to run server-side or client-side?

I believe you're mixing VBScript with JavaScript/JScript...

Plus, there's lots more than the connection string to worry about...
<html>
<title>Test</title>
<head>
<script language="javas cript">
We'd probably prefer to write

<script type="text/javascript">

but that's not related to your problem...
<!--
Function showForm(){
JavaScript is case sensitive, and this should be

function showForm() {

var conn
conn = CreateObject("A DODB.Connection ");
Should be, I believe:
conn = new ActiveXObject(" ADODB.Connectio n");

var rst
var = CreateObject("A DODB.recordset" );
var sql
Should be, maybe rst= new ActiveXObject(. ..etc...)?
instead of var=CreateObjec t(...etc...)

Note, on these 2 lines, we're expecting a client-side database. You may
get security warnings or may die all together.
sql = "select f01, f02 from IT_ASP where id < 10";
conn.Open "Provider=SQLOL EDB.1;Persist Security Info=False;User
ID=sa;Initial Catalog=Projekt ;Data Source=MYSERVER \MYSQL;pwd=123A bc.";
Looks like VB syntax above. In js put the connection string in ()'s.
conn.Open("..." ) --or--

var connectionStrin g = " ... "
conn.Open(conne ctionString);
rst.Open (sql, conn);
while (!rst.EOF){
document.write( rst(0));
I suspect a problem with the above line. What, really, is rst(0)? Is it
a record? The write() method takes string arguments or converts the
argument to string before writing.

Actually you maybe need rst.Fields(0) or something like that for the
field you want. Else you may have data type problems.
document.write( "<br>");
rst.MoveNext;
above s/b rst.MoveNext();
}
rst.Close;
above s/b rst.Close();
rst=Nothing;
The above line is VB, not javascript. Delete it.
document.close;
I think this also is document.close( );

It's a *method*, which is a function, so you need the function operator ()
}
//-->
</script>
</head>
<body>
<form name="myform" action="">
<input name="but1" type="button" value="klick"
onClick="javasc ript:showForm() ">
In the above, lose the "javascript :". It's just

onClick="showFo rm()"
</form>
</body>
</html>
Other points ...
Figuring out what the connection string is one of the hardest things
about ADO for me. I don't know if that's correct for your case or not.

This coding assumes that the database is on the client, not server. If
the database is on the server, use ASP.

I know with, say, a VB program you could connect to a database across
the 'net via ADO. I don't know if you'll run into security problems or
not trying to do that from within a web page. My guess is probably so.
I'm still getting an error: object expected.
What's wrong? (I know, it's late...)
Andy


Lots of debugging to do. Make sure you use *javascript* syntax
throughout. Dont confuse with VBScript. Or give up on js and *just* use
VBScript.

Don't know that I found everything, but this is a start, at least....

Stephen

Jul 20 '05 #5
Hi Richard,

Richard Cornford wrote:
"Andy Wawa" <aw*********@ar cor.de> wrote in message
news:3f******** *************** @news.frii.net. ..
<script language="javas cript">
<!--
Function showForm(){
var conn
conn = CreateObject("A DODB.Connection ");

I think that CreateObject is VBScript not JavaScript.


Actually, CreateObject as such is part of ASP, and can be used in
VBScript, JScript or any language supported by ASP. It's just an API method.

On ASP (server-side), it's perfectly legal to use CreateObject to
instantiate COM components. That's the beauty (IMHO) of ASP, and now of
..NET: The platform expose a set of objects which can be used with the
same signature in any supported language. This allows you to choose
whichever language you prefer without losing the efficiency of the platform.

Laurent
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #6
Hi,
I really mixed VBScript and JavaScript! Unfortunately I have to script
it on the client-side, so an ASP-Solution can't be used (I only have
access at this one special SQL-Server table and nothing more)...
The proper script looks like that:

<SCRIPT type="text/javascript">
<!--
function Aufruf(){
var rst;
var dsn;
var sql;
var newWindow;
rst = new ActiveXObject(" ADODB.Recordset ");
dsn = new ActiveXObject(" ADODB.Connectio n");
dsn.Open ("Provider=SQLO LEDB.1;Persist Security Info=False;User
ID=myID;Initial Catalog=Projekt ;Data Source=MyServer ;pwd=mypass");
sql = ("select gpar_name1, gpar_name2 from adress");
rst.Open (sql, dsn);
newWindow = window.open("", "","width=6 00, height=400,top= 200
left=200,scroll bars");
while (!rst.EOF){
newWindow.docum ent.write(rst(0 ) + " " + rst (1));
newWindow.docum ent.write("<br> ");
rst.moveNext();
}
rst.Close();
}

Thanks for your help, advices and tips :-))
Andy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7

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

Similar topics

2
3261
by: Mike Moore | last post by:
We are developing an asp.net web application. When we drag and drop the sql connection object to the form we set the in the dynamic properties connection string to use the connection string in the web.config file. Works Great except everytime we need drag and drop a new data adapter on the form we automatically creates a new connection sql string object.
3
15404
by: Andrew Johnson | last post by:
Hi, I am trying to make a UBD DB2 7.2 connection using the Java COM.ibm.db2.jdbc.app.DB2Driver via Tomcat 3.2.1 on Solaris (and also on an AIX system with 3.3.1). I am attempting this either via JSP or a servlet. I have a separate java application that I can run from the command line and as long as the user has the correct env variables:
2
2236
by: Ken | last post by:
How can I copy data from SQL to MS Access using dsn-less connection and not using SQL DTS? I have this but am stuck. I just want to do an export but can't figure out how to do a "select into". It pastes the data in SQL instead of access. The below code will cycle but I will have to create a table to place the data first. Is there an easier way. Sub getTables() Dim cnnSQL As ADODB.Connection Dim cnnMSA As ADODB.Connection
2
2128
by: Jim | last post by:
Is it possible to have a Connection class that opens up connection to my DB and leaves it open until I decide to close it? I run many SQL statements so I was wondering if it's possible to call a Class1.GetProducts that sets up an SQL statement and then calls another Class2.Connect that actually opens up the connection Class2.Connect would not receive anything (since the connections string is always the same) and would not return anything....
3
1747
by: Wing | last post by:
Hi all, I am writing the C# code function that take 2 parameters and access the data in the MS SQL database and return a SqlDataReader object. In my funtion, a SQL connection is established and open the connnection before reading the data. Everything seem to be fine, but once I add the close() function to close the sql connection, error come out. So I leave out the close() function in my function. My code is showing below ...
7
2262
by: greg | last post by:
Hi We have w2k, iis5, .NET/c# I periodically receive this message and the system freezes ++++++++++++++++++++++++++++++++++++++++++++++++++ Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in
6
1240
by: Backwards | last post by:
I'm using visual studio 2005 and SQL 2000, trying to connect to a sql database as a differnent user. Here is my current connection string that is using my own NT login: Dim message As String = "Data Source=" + Me.ComboBox1.Text.ToString() + ";Initial Catalog=Store;Integrated Security=SSPI" Dim sql As New SqlClient.SqlConnection(message)
0
1318
by: Arielle | last post by:
Please tell me what's wrong with this picture. public class MyClass { SqlConnection ConnectionSql = null; SqlCommand CommandSql = null; SqlDataReader QueryResult = null;
9
1296
by: rcoco | last post by:
Hi, I'm just wondering if I'm on the write truck. this code is ment to look for an ID number in the datagrid that matches the the ID number that is in the textbox I created. But it's not selecting neither is it showing me any error. could some one help me please? private void bttok_click(object sender, System.EventArgs e) { SqlCommand myCommand = new SqlCommand("select * from employee where
0
1982
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I could see what is the SQL that freezes the program. I wanted to replicate this for VB.NET, but the SqlConnection object does not seem to support nearly as rich a set of events as the ADODB.Connection object. Any ideas where these events went,...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.