谁能帮我把这段vb.net代码转成c#的?万分感谢!!
<%@ImportNamespace="System.Data"%><%@ImportNameSpace="System.Data.OleDb"%><%@ImportNa...
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<%@ Import NameSpace="System.Web.UI.UserControl" %>
<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("1.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
'la1.text="Connection Opened!"
myCommand = New OleDbCommand( "select News_Phone FROM BM_Article where id=3", myConnection )
MyDataGrid.DataSource=myCommand.Executereader()
MyDataGrid.DataBind()
end sub
</script>
<asp:Repeater ID="MyDataGrid" runat="server">
<ItemTemplate>
<%# Eval("News_Phone") %>
</ItemTemplate>
</asp:Repeater>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script language = "C#" runat = "server" >
OleDbConnection myConnection;
OleDbCommand myCommand;
void Page_Load ( object sender , EventArgs e )
{
string dbname;
dbname = Server.MapPath("1.mdb");
myConnection = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname ) ;
myConnection.Open() ;
//la1.text="Connection Opened!" ;
myCommand = new OleDbCommand( "select News_Phone FROM BM_Article where id=3", myConnection );
MyDataGrid.DataSource=myCommand.Executereader();
MyDataGrid.DataBind();
}
</script>
<asp:Repeater ID="MyDataGrid" runat="server">
<ItemTemplate>
<%# Eval("News_Phone") %>
</ItemTemplate>
</asp:Repeater>
行 20: MyDataGrid.DataSource=myCommand.Executereader();
CS0117: “System.Data.OleDb.OleDbCommand”并不包含“Executereader”的定义 展开
<%@ Import NameSpace="System.Data.OleDb" %>
<%@ Import NameSpace="System.Web.UI.UserControl" %>
<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("1.mdb")
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="&dbname )
myConnection.Open()
'la1.text="Connection Opened!"
myCommand = New OleDbCommand( "select News_Phone FROM BM_Article where id=3", myConnection )
MyDataGrid.DataSource=myCommand.Executereader()
MyDataGrid.DataBind()
end sub
</script>
<asp:Repeater ID="MyDataGrid" runat="server">
<ItemTemplate>
<%# Eval("News_Phone") %>
</ItemTemplate>
</asp:Repeater>
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script language = "C#" runat = "server" >
OleDbConnection myConnection;
OleDbCommand myCommand;
void Page_Load ( object sender , EventArgs e )
{
string dbname;
dbname = Server.MapPath("1.mdb");
myConnection = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname ) ;
myConnection.Open() ;
//la1.text="Connection Opened!" ;
myCommand = new OleDbCommand( "select News_Phone FROM BM_Article where id=3", myConnection );
MyDataGrid.DataSource=myCommand.Executereader();
MyDataGrid.DataBind();
}
</script>
<asp:Repeater ID="MyDataGrid" runat="server">
<ItemTemplate>
<%# Eval("News_Phone") %>
</ItemTemplate>
</asp:Repeater>
行 20: MyDataGrid.DataSource=myCommand.Executereader();
CS0117: “System.Data.OleDb.OleDbCommand”并不包含“Executereader”的定义 展开
展开全部
差不多就这样了,可能有小出入,自己改改吧
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<%@ Import NameSpace="System.Web.UI.UserControl" %>
<script laguage="C#" runat="server">
OleDbConnection myConnection;
OleDbCommand myCommand;
page_load(Object sender, EventArgs e)
{
string dbname;
dbname=server.mappath("1.mdb") ;
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname ) ;
myConnection.Open() ;
//la1.text="Connection Opened!" ;
myCommand = New OleDbCommand( "select News_Phone FROM BM_Article where id=3", myConnection );
MyDataGrid.DataSource=myCommand.Executereader() ;
MyDataGrid.DataBind();
}
</script>
<asp:Repeater ID="MyDataGrid" runat="server">
<ItemTemplate>
<%# Eval("News_Phone") %>
</ItemTemplate>
</asp:Repeater>
他抱什么错?
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<%@ Import NameSpace="System.Web.UI.UserControl" %>
<script laguage="C#" runat="server">
OleDbConnection myConnection;
OleDbCommand myCommand;
page_load(Object sender, EventArgs e)
{
string dbname;
dbname=server.mappath("1.mdb") ;
myConnection = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname ) ;
myConnection.Open() ;
//la1.text="Connection Opened!" ;
myCommand = New OleDbCommand( "select News_Phone FROM BM_Article where id=3", myConnection );
MyDataGrid.DataSource=myCommand.Executereader() ;
MyDataGrid.DataBind();
}
</script>
<asp:Repeater ID="MyDataGrid" runat="server">
<ItemTemplate>
<%# Eval("News_Phone") %>
</ItemTemplate>
</asp:Repeater>
他抱什么错?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询