Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just can't figure out what it wants

Status
Not open for further replies.
May 10, 2002
77
US
Please help. I'm attaching to my sql database via a dsn but everytime I try to run the page, it tells me that it expects a ; after Sub Page_Load??? It is only a few lines of code and shouldn't need a ; . I'm so confused and I am new to this. I have included the code so you could see if I am missing something. Thanks so much in advance!

<%@ Import Namespace="System.Data.OleDb" %>
<Script runat="Server">
Sub Page_Load
Dim conDB As sqlcon
conDB = New sqlcon
( "Provider=Microsoft.Jet.OLEDB.4.0;Data Soure="MYDSN" )
conDB.Open()
End Sub
</script>
 
it's not a javascript error?

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
You havent specified a language for the script, i think its language="VB" in the <SCRIPT> tag... Maybe its defaulting to C#
 
I did try adding a language= in the script tag but it still returns the same error. I've searched heavily for how to connect and nothing I have seen dictates that I would need to specify a language to use, but I have tried that. Thanks! That's why I am stumped. This is also a page by itself, no other code on the page to search above the line for an error.
 
This line definitley looks funny.
Code:
 ( "Provider=Microsoft.Jet.OLEDB.4.0;Data Soure="MYDSN" )

Is the connection string getting cut off at the end? Maybe try
Code:
 ( "Provider=Microsoft.Jet.OLEDB.4.0;Data Soure=MYDSN" )

or maybe
Code:
 ( "Provider=Microsoft.Jet.OLEDB.4.0;Data Soure=MYDSN;")

Just a thought,
FD
 
Ok, thanks. But now I am getting sqlcon is not defined on line

Dim conDB As sqlcon

I can't believe connecting to a DB can be this difficult.
 
Try

Code:
Dim conDB as New sqlcon


tigerjade

"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding


 
Am I missing something? What is a sqlcon? What is a Data Soure?

Dim conDB as SqlConnection()
conDb = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MYDSN;")

Also don't put quotes around "MYDSN".
 
>>Dim conDB As sqlcon

what is sqlCon??? there is a sqlConnection, oledbConnection...

Known is handfull, Unknown is worldfull
 
<blush> caught me with my brain hanging from one ear </blush>

tigerjade

"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding


 
now it's saying sqlconnection is not defined?? Maybe I'm going in the wrong direction all together. I'm trying to connect to my sql server via a DSN.
 
Thanks vbkris. I freaked out and missed the obvious also - he's using Access:

Dim conDB as OleDbConnection()
conDb = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MYDSN;")
 
Change
<%@ Import Namespace="System.Data.OleDb" %>
to
<%@ Import Namespace="System.Data.OleDbClient" %>
use
oledbconnection and not sqlconnection (if u r using DSN)

but why would u want to use DSN? why not directly use the sqlconnection?
<%@ Import Namespace="System.Data.SqlClient" %>

conDb = new SqlConnection("Server=SERVERNAME;UserId=USERNAME;Pwd=PASSWORD;Database=DBNAME;")
The connection string may be wrong (i got it out of my memory) please check it with some material


Known is handfull, Unknown is worldfull
 
Just a quick note, i haven't read through the whole thread, but it seems you've mispelled Source:
Code:
 ( "Provider=Microsoft.Jet.OLEDB.4.0;Data [b]Soure[/b]="MYDSN" )
 
OLEConnection undefined. This is frustrating. I was using a dsn for security reason. The VP doesn't like the fact of putting a static username and password in the script which can be seen in clear text.
 
I didn't copy and paste it here. I checked to be sure but it is spelled correctly in the page. Thanks for noticing that though.
 
A shot in the dark, did you define the dsn on the host machine? Did you name it MYDSN? On the machine your page is runnin on?
 
Here's the expanded error message. Maybe this will help. It almost looks like it cannot find system.data.oledbclient to import??? I really appreciate all the help also!!!!

Microsoft (R) Visual Basic .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322.2032
Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\fa\23130c48\aa5b4a87\ikbqwgot.0.vb(20) : error BC30466: Namespace or type 'OleDbClient' for the Imports 'System.Data.OleDbClient' cannot be found.

Imports System.Data.OleDbClient
~~~~~~~~~~~~~~~~~~~~~~~
c:\inetpub\ : error BC30002: Type 'OleDbConnection' is not defined.

Dim conDB As OleDbConnection
~~~~~~~~~~~~~~~
c:\inetpub\ : error BC30002: Type 'OleDbConnection' is not defined.

conDB = New OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;DATA Source=FADSN" )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top