<%@ Page Language="C#" Debug="true" %>
<html>
<body>
<form runat=server >
<span id="la1" runat=server />
<button id="ss" runat=server >我是科比</button><br>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script laguage="VB" runat="server">
Dim myConnection As OleDbConnection;
Dim myCommand As OleDbCommand;
sub page_load(sender as Object,e as EventArgs)
dim dbname as string
dbname=server.mappath("asp.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
la1.innertext="Connection Opened!"
end sub
</script>
</form>
</body>
</html>错误提示: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: ; expectedSource Error: Line 8: <%@ Import NameSpace="System.Data.OleDb" %>
Line 9: <script laguage="VB" runat="server">
Line 10: Dim myConnection As OleDbConnection;
Line 11: Dim myCommand As OleDbCommand;
Line 12: sub page_load(sender as Object,e as EventArgs)
Source File: H:\web\index.aspx Line: 10
<html>
<body>
<form runat=server >
<span id="la1" runat=server />
<button id="ss" runat=server >我是科比</button><br>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script laguage="VB" runat="server">
Dim myConnection As OleDbConnection;
Dim myCommand As OleDbCommand;
sub page_load(sender as Object,e as EventArgs)
dim dbname as string
dbname=server.mappath("asp.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
la1.innertext="Connection Opened!"
end sub
</script>
</form>
</body>
</html>错误提示: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: ; expectedSource Error: Line 8: <%@ Import NameSpace="System.Data.OleDb" %>
Line 9: <script laguage="VB" runat="server">
Line 10: Dim myConnection As OleDbConnection;
Line 11: Dim myCommand As OleDbCommand;
Line 12: sub page_load(sender as Object,e as EventArgs)
Source File: H:\web\index.aspx Line: 10
解决方案 »
- 我还想用js处理一下<%#eval("")%>里的变量,怎么办呢?
- 使用window.open打开子页面,然后使用javascript在子页面取得checkboxlist的ID问题
- 在ASP.NET页面上弹出一个类似与windowForm的Message.Show()的对话框
- Microsoft.XMLHTTP和DIV的问题
- 控制页面转向
- .net 当中如何将 .js,.jpg 类似于这种资源文件编译到.dll中
- Powered by 是什么意思??
- Word.Application 数据类型,该导入什么命名空间?
- 如何建立一个下拉列表的树形列表?
- 在线等待,立马给分!!怎样获取登录的用户信息,如IP,并发信息给他
- [Help]使用C#来写ASP.NET时定义的static变量是存放在哪里的?还有如何声明一个Application.StaticObjects?
- ASP.NET调用DLL的问题!(在线急等!!!!来者有分!!!)
还有楼主的数据库连接不要写在page_load里。
这样很不好!!!。
using System;
using System.Web;
using System.Data;
using System.Collections;
using System.Data.SqlClient;
namespace _sssxx
{
/// <summary>
/// DataConnection 的摘要说明。
/// </summary>
public class DataConnection
{
public DataConnection()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public SqlConnection sqlConn;
#region 数据库的连接
public void GetLoadConnection()
{
try
{
string strConnection = "";
//从配置文件连接数据库
strConnection = System.Configuration.ConfigurationSettings.AppSettings["cnndb"];
sqlConn = new SqlConnection(strConnection.Trim());
sqlConn.Open(); }
catch(Exception ex)
{
throw new Exception(ex.ToString());
} }
#endregion
#region 退出删除连接,删除数据
public void Quit()
{
try
{
sqlConn.Close();
sqlConn.Dispose();
}
catch(Exception ex)
{
sqlConn.Close();
sqlConn.Dispose();
throw new Exception(ex.ToString());
}
}
#endregion
#region 执行有返回值的SQL语句
public DataSet GetQueryData(string strTableName,string strSql)
{
DataSet ds = new DataSet();
try
{
GetLoadConnection();
SqlCommand sqlCommand = new SqlCommand(strSql);
sqlCommand.Connection = sqlConn;
sqlCommand.ExecuteNonQuery();
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCommand);
SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(sqlDa);
if(strTableName == null || strTableName.Trim() == "")
{
sqlDa.Fill(ds);
ds.Tables[0].ExtendedProperties.Add("da",sqlDa);
}
else
{
sqlDa.Fill(ds,strTableName);
ds.Tables[strTableName].ExtendedProperties.Add("da",sqlDa);
}
}
catch(Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
sqlConn.Close();
sqlConn.Dispose();
}
return ds;
}
#endregion }
}
Line 10: dbname="H:\web\asp.mdb"
Line 11: myConnection = New OleDbConnection ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname)
Line 12: myConnection.Open()
Line 13: la1.text="Connection Opened!"
Line 14: end sub
Source File: H:\web\index.aspx Line: 12