syntax error?<%@ Import Namespace="System.Data" %>
hi, could someone please help --------
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
OleDbConnection objConnection;
OleDbConnection objCommand;
string strConnect;
string strCommand;
DataSet DataSet1 = new DataSet();
strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;";
//If you don't have the grocertogo.mdb database then
//you will have to change the following three lines
strConnect += @"Data Source=C:\program files\microsoft.net\FrameworkSDK\";
strConnect += @"Samples\quickstart\assplus\samples\grocertogo\da ta";
strConnect += @"\grocertogo.mdb;";
strConnect += "Persist Security Info=False";
strCommand = "SELECT ProductName, UnitPrice FROM Products";
objConnection = new OleDbConnection(strConnect);
objCommand = new OleDbDataAdapter(strCommand, objConnection);
objCommand.Fill(DataSet1, "products");
DataGrid1.DataSource=DataSet1.Tables["Products"].DefaultView;
DataGrid1.DataBind();
}
</script>
<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid ID="DataGrid1" runat="server" />
</body>
</html>
---------------
and i am getting this 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: CS0029: Cannot implicitly convert type 'System.Data.OleDb.OleDbDataAdapter' to 'System.Data.OleDb.OleDbConnection'
Source Error:
Line 23: strCommand = "SELECT ProductName, UnitPrice FROM Products";
Line 24: objConnection = new OleDbConnection(strConnect);
Line 25: objCommand = new OleDbDataAdapter(strCommand, objConnection);
Line 26: objCommand.Fill(DataSet1, "products");
Line 27: DataGrid1.DataSource=DataSet1.Tables["Products"].DefaultView;
-----------
also, a squigley line is under <%@ Namespace="System.Data" %> - and when hovering over it it says - "syntax error"
any help would be much appreciated,
sincerely
|