将vb转成c#的代码,100分

hiweiyi2000 2004-11-07 06:00:15
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<Script runat="Server">

Sub Page_Load
Dim conNorthwind As SqlConnection
Dim cmdCategories As SqlCommand
Dim dstCategories As DataSet
Dim strQuery As String

conNorthwind = New SqlConnection( "Server=localhost;UID=sa;PWD=secret;Database=Northwind" )
strQuery = "select CategoryName As Text, 'products.aspx?catid=' + LTRIM( STR( CategoryID ) ) " & _
"As TreeNodeSrc from Categories As TreeNode for xml auto, XMLDATA"
cmdCategories = New SqlCommand( strQuery, conNorthwind )
conNorthwind.Open()
dstCategories = New DataSet
dstCategories.ReadXml( cmdCategories.ExecuteXmlReader(), XmlReadMode.Fragment )
dstCategories.DataSetName = "TREENODES"
dstCategories.WriteXml( Response.OutputStream )
conNorthwind.Close()
End Sub

</Script>
...全文
109 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
meilixueshan2009 2004-11-07
来晚了,顶一下
回复
popstartzhang 2004-11-07
我也来学习一下。
回复
jianli0108 2004-11-07
楼上的网站试了试,还不错,收藏了
回复
webserv2 2004-11-07
晕,来晚了!

http://www.developerfusion.com/utilities/convertcsharptovb.aspx

以后可以自己转了,不用发帖了!

授人以渔

嘿嘿!
回复
孟子E章 2004-11-07
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
void Page_Load(Object sender, EventArgs e){
SqlConnection conNorthwind;
SqlCommand cmdCategories;
DataSet dstCategories;
string strQuery;
conNorthwind = new SqlConnection("Server=localhost;UID=sa;PWD=secret;Database=Northwind");
strQuery = "select CategoryName As Text, 'products.aspx?catid=' + LTRIM( STR( CategoryID ) ) " + "As TreeNodeSrc from Categories As TreeNode for xml auto, XMLDATA";
cmdCategories = new SqlCommand(strQuery, conNorthwind);
conNorthwind.Open();
dstCategories = new DataSet();
dstCategories.ReadXml(cmdCategories.ExecuteXmlReader(), XmlReadMode.Fragment);
dstCategories.DataSetName = "TREENODES";
dstCategories.WriteXml(Response.OutputStream);
conNorthwind.Close();
}
</script>
回复
孟子E章 2004-11-07
<%@ Page Language="C#"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>

<script runat="server">
void Page_Load(Object sender, EventArgs e){
SqlConnection conNorthwind;
SqlCommand cmdCategories;
DataSet dstCategories;
string strQuery;
conNorthwind = new SqlConnection("Server=localhost;UID=sa;PWD=secret;Database=Northwind");
strQuery = "select CategoryName As Text, 'products.aspx?catid=' + LTRIM( STR( CategoryID ) ) " + "As TreeNodeSrc from Categories As TreeNode for xml auto, XMLDATA";
cmdCategories = new SqlCommand(strQuery, conNorthwind);
conNorthwind.Open();
dstCategories = new DataSet();
dstCategories.ReadXml(cmdCategories.ExecuteXmlReader(), XmlReadMode.Fragment);
dstCategories.DataSetName = "TREENODES";
dstCategories.WriteXml(Response.OutputStream);
conNorthwind.Close();
}
回复
相关推荐
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2004-11-07 06:00
社区公告
暂无公告