preetham.n
July 12th, 2008, 02:14 AM
Hi all,
Need a little help, a very basic one at that.
Am new to C# and the Visual c# 2005 Express Edition IDE. Am trying to connect to an access database through c#, but to no joy (faltering at the first step).
Below is the code that I have typed in. Even this basic code gives me problems.
First the IDE does not recognise "conn", because i guess the open() method sgould show up automatically on intellisense when i type a dot after conn but I dont get anything. When I compile the error comes up at the open method where it says Invalid token '(' in class.
I have added reference to system.data dll.
I know its basic stuff but can some one help?
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data; // State variables
using System.Data.ADO; // Database
using System.Globalization; // Date
namespace Ticket_Order
{
public class dbFunctions
{
string connString = @"provider = microsoft.jet.oledb.4.0;data source = Employee.mdb;";
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
}
}
Need a little help, a very basic one at that.
Am new to C# and the Visual c# 2005 Express Edition IDE. Am trying to connect to an access database through c#, but to no joy (faltering at the first step).
Below is the code that I have typed in. Even this basic code gives me problems.
First the IDE does not recognise "conn", because i guess the open() method sgould show up automatically on intellisense when i type a dot after conn but I dont get anything. When I compile the error comes up at the open method where it says Invalid token '(' in class.
I have added reference to system.data dll.
I know its basic stuff but can some one help?
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data; // State variables
using System.Data.ADO; // Database
using System.Globalization; // Date
namespace Ticket_Order
{
public class dbFunctions
{
string connString = @"provider = microsoft.jet.oledb.4.0;data source = Employee.mdb;";
OleDbConnection conn = new OleDbConnection(connString);
conn.Open();
}
}