Click to See Complete Forum and Search --> : building a db connection in an asp.net site


martha
12-28-2004, 02:05 PM
I am trying to connect to a db doing this:
Application>Databases>OLE DB Connection, I enter the conn name, and I press Build which (according to a book I'm reading) should open a data link properties dialog box.
Instead, I press Build and nothing happens? Can u give any help please, cause I'm stuck.
Thank You! ;)

baseiber
12-28-2004, 02:43 PM
Are you using a wizard to do this? If not please post your code.

martha
12-28-2004, 02:45 PM
No, I don't have any code, I'm doing it in Dreamweaver

PeOfEo
12-28-2004, 02:56 PM
I am assuming you are using access (oledb), but if you are not I can also help you with sql server.

Put this at the top of your page

<%@ Import Namespace="System.Data.OLEDB" %>

That is the proper namespace for oledb


Here is one of my access connection strings

Dim DBConn as OleDbConnection
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("/yourdb.mdb;"))

I am just setting dbconn as the connection, dbconn will now the the variable name of my connection. I am saying that it is an oledb connection and that this is microsoft jet oledb 4 (access). The I just say where the thing is and that is it. There are other things you can include (like if your database has a password / user id you will need to include that), but this is just the most basic way to connect to an access db.

If you are connecting to this db on many pages you can actually put the connection string inside of the web.config and just use a reference to the web.config on your pages.

martha
12-28-2004, 04:15 PM
Ok u r right.
But the next problem is that although I've tested the connection and it is succesfuly made, (I can see it in Application > Databases), when I click the + sign on the tables, I get NONE.
And I am sure it is my one and only database I can possibly connect, plus I tried to do the same using ASP VBscript and I got all of my tables.
What is going wrong?
Please help again! :confused:

PeOfEo
12-28-2004, 10:36 PM
+ sign on the tables?

martha
12-29-2004, 01:32 AM
yes, I am using dreamweaver and I get the database but I donīt get the tables :(

PeOfEo
12-29-2004, 02:35 AM
Originally posted by martha
yes, I am using dreamweaver and I get the database but I donīt get the tables :( Why does that matter? If you can access the tables with a script you are golden.

martha
12-29-2004, 04:07 AM
Thatīs the problem; I access the db but I dont get my tables:(
Suppose I want to create a recordset, I get the connected db, but when it comes to the tables I get NONE

PeOfEo
12-29-2004, 05:10 AM
Originally posted by martha
Thatīs the problem; I access the db but I dont get my tables:(
Suppose I want to create a recordset, I get the connected db, but when it comes to the tables I get NONE But if you can do it with a script then I do not see what the problem is. I mean you said earlier you got the tables from an asp vbscript right?

martha
12-29-2004, 05:53 AM
Yes, but the site I create is ASP.NET with VB.
I just tested if I can get the tables using ASP VBscript and I got them.
But my new site is based on ASP.NET with VB and though I make the connection, I get the database but not the tables. ggggrrr

PeOfEo
12-29-2004, 03:23 PM
I can't understand why you would be able to see the tables in classic but not from .net.... I know there are some weird permissions issues, like if simple share needs to be turned off and asp.net needs to have proper privleges to update the db. But I can't think of why you would be able to connect but not see the tables unless the tables do not exist, which you say they do. Is there anyway you can rebuild the db?

martha
12-29-2004, 03:47 PM
I also did run the path from the windows start run menu, and it opened the database including of course the tables.
You are right about simple share that needs to be turned off (I did it before creating the connection) but what did u mean by asp.net needs to have proper privleges to update the db Maybe is there something I didn't do?
You see I'm doing all this work according to a book DREAMWEAVER MX2004 AND DATABASES. I tried to contact the author for help, but his mail address is invalid:mad:
And I need to find a solution because I was working in a site using classic ASP but I want to learn working using ASP.net.
Thanks for your concern anyway:rolleyes:

PeOfEo
12-29-2004, 04:03 PM
Well with asp.net you have a system account on the machine, its aspnet. With asp classic you have iusr. Aspnet will need the same permissions Iusr has.

martha
12-29-2004, 04:23 PM
OK:)
I found out!
It is a problem created installing xp service pack.
I fixed it! Check this out in case you ever need it http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_19515#aspnet_db
Thanks again for your concern!;)
Here it's 22:23 so goodnight for me and have a nice rest of the day for you