Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP.NET (Non-Forum Related)
 What's wrong?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

alextam
Starting Member

Hong Kong
42 Posts

Posted - 16 September 2003 :  11:51:42  Show Profile  Visit alextam's Homepage  Send alextam an ICQ Message
<%@ Import Namespace="System.Data.OleDb" %>
<script language="C#" runat="server">
//Global Variables
OleDbConnection Conn;

void DBConnect(String SQL, String DB) {
		 OleDbCommand Cmd;
		 String Provider = "Provider=Microsoft.Jet.OLEDB.4.0";
		 String Database = "Data Source=" + Server.MapPath(Db);
		 Conn = New OleDbConnection (Provider + ";" + Database) ;
		 Conn.open();
		 Cmd = New OleDbCommand(SQL,Conn);
		 Return Cmd.ExecuteReader();
}

void CloseConn() {
		 Conn.close();
}
</script>


I got the error:

Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1002: ; expected

Source Error:

 

Line 8:  		 String Provider = "Provider=Microsoft.Jet.OLEDB.4.0";
Line 9:  		 String Database = "Data Source=" + Server.MapPath(Db);
Line 10: 		 Conn = New OleDbConnection (Provider + ";" + Database) ;
Line 11: 		 Conn.open();
Line 12: 		 Cmd = New OleDbCommand(SQL,Conn);
 

Thanks a lot!
Regards.

alextam
Starting Member

Hong Kong
42 Posts

Posted - 16 September 2003 :  11:53:16  Show Profile  Visit alextam's Homepage  Send alextam an ICQ Message
Sorry, forgot to include...it's line 10

Thanks a lot!
Regards.
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 16 September 2003 :  14:49:09  Show Profile  Visit Nathan's Homepage
Look at line 10 . . . there is a space that should not be there.

Nathan Bales
CoreBoard | Active Users Download
Go to Top of Page

alextam
Starting Member

Hong Kong
42 Posts

Posted - 17 September 2003 :  00:16:15  Show Profile  Visit alextam's Homepage  Send alextam an ICQ Message
Sorry, that's not the error source. I have tried...

are there any articles teaching connecting to Access using C#?

Thanks a lot~~

Thanks a lot!
Regards.
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 17 September 2003 :  00:26:42  Show Profile  Visit Gremlin's Homepage
I'm only guessing here, try adding the bit in red (though I don't really know if it makes a difference)

Conn = New OleDbConnection (Provider + ";" + Database + ";")

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 17 September 2003 :  03:59:05  Show Profile  Visit Nathan's Homepage
The argument should be formatted something like this.

OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\myDatabase.mdb");

Nathan Bales
CoreBoard | Active Users Download
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.19 seconds. Powered By: Snitz Forums 2000 Version 3.4.07