谁能帮我把这段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”的定义
展开
 我来答
ourcolour
2007-02-03 · TA获得超过510个赞
知道小有建树答主
回答量:376
采纳率:0%
帮助的人:250万
展开全部
差不多就这样了,可能有小出入,自己改改吧

<%@ 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>

他抱什么错?
五库全书
2007-02-03 · TA获得超过340个赞
知道小有建树答主
回答量:524
采纳率:0%
帮助的人:292万
展开全部
平台不是通用么?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式