.net连接oracle出错,不明白!!
做了两个页
第一个页面:
用的是从.net工具箱的数据选项中拖拽到1.aspx的dataview,在设计版面中配置数据源,查询表.运行成功显示表中的数据记录.
第二个是用手写的
代码如下:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default2.aspx.cs " Inherits= "Default2 " Debug= "true " %>
<%@ Import Namespace= "System.Data " %>
<%@ Import Namespace= "System.Data.OleDb " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<asp:DataGrid HeaderStyle-BackColor= "red " ID= "dataGrid1 " runat= "server " OnSelectedIndexChanged= "dataGrid1_SelectedIndexChanged ">
</asp:DataGrid>
<script language= "c# " runat= "server ">
void Page_Load(Object sender, EventArgs E)
{
DataSet ds = new DataSet();
String Connstr2 = "Provder=OraOleDb.Oracle.1:Persist Security Info=True;User ID=****;Data Source=1000;Password=123456;Unicode=True; ";
String sql = "select * from cdb_matchscore ";
OleDbConnection odconn = new OleDbConnection(Connstr2);
/*odconn.Open;*/
OleDbCommand odcomm = new OleDbCommand(sql, odconn);
OleDbDataAdapter odadp = new OleDbDataAdapter();
odadp.SelectCommand = odcomm;
odadp.Fill(ds, "cdb_matchscore ");
dataGrid1.DataSource = ds.Tables[ "cdb_matchscore "].DefaultView;
dataGrid1.DataBind();
}
</script>
</body>
</html>
运行结果:
“/WebSiteTest”应用程序中的服务器错误。
--------------------------------------------
在 &