DB Conn - Help!

U

[UKLans]Khan

Guest
Hello!

I am in the process of learning ASP.net using VB. I understand the basics and I am very impressed.... BUT!!! I can't find anywhere that shows you how to connect to a Microsoft Access Database and the connection string!!!

Oh and I connect to the DB using a DNS connection.

Have any of u guys seen/done this?

Cheers,

Khan
 
O

old.Jas

Guest
Its done in almost exactly the same way as ASP
 
O

old.LeitMotif

Guest
You want to be looking at the System.Data.OleDb namespace

Purely as an insert Example;

Code:
using System;
using System.Data.OleDb;

class MyClass
{
	public MyClass()
	{

	}

	public static void AddNewUser()
	{
		string sqlStatement;

		OleDbConnection dbC = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0; Data Source=path\to\access.mdb");

		sqlStatement = "INSERT INTO myTable (f1,f2,f3) VALUES ("val1","val2","val3") 
		OleDbCommand dbCom = new OleDbCommand(sqlStatement,dbC);

		dbC.Open();
		dbCom.ExecuteNonQuery();
		dbC.Close();

	}
}

you need to make sure you close off connections and dispose of objects properly though.
 
O

old.LeitMotif

Guest
i think that will work it was written from memory and ive not touched .net/C# for a good 7 months.


//added .... having read your post in full :/

im not sure about DSN's you may need to use the ODBC.NET extensions which would need to be installed on the host.. however DSN's arent mandatory and i rarely use them in connection strings with web applications anyway.
 
U

[UKLans]Khan

Guest
Thanks for your help guys, I found a couple of articles last night, there's just one thing that I can't find - Using normal ASP I connected to a DSN on the host machine, using ASP.NET it seems that it only uses a DSN-Less connection [Showing the full path of the DB]. Am I being dumb? [ :) ]

Khan
 
U

[UKLans]Khan

Guest
Thanks, Its a very good site. I gonna start with .net toady and try and do a little game project to see give me some experiance with .net

Do you guys use .net now or do some of you still use asp classic?

Cheers,

Khan
 
O

old.LeitMotif

Guest
.Net is more of a hobby language at the moment, we are finding that our large customers are not yet willing to move into the .Net realm. Which means that alot of the development is still ASP, PHP and PERL (and vb6 for form based apps).

i wont deny that i do like c# alot, but i dont have enough hours in the day to learn another technology off my own back.

:)
 
U

[UKLans]Khan

Guest
I know what you mean, I think 38 hours a day would do me :)

I do think that Microsoft have made a very positive move with there .Net appliactions, and asp has been given a new lease of life!!

Khan
 
O

old.LeitMotif

Guest
well.. its positive but its been around for many years in the form of the java framework..

all ms are allowing sales man to do is the buzz words and buzz phrases like separation and framework and all that rubbish.. but as a product it does seem promising.
 

Users who are viewing this thread

Top Bottom