代码转换!把c#代码转换成vb.net代码

liao108 2008-01-11 11:35:06
请各位帮帮忙,把下面C#代码转换成VB.NET代码

public static string getinsertsql(datatable table)
{
string sqlstr = "";
foreach (datarow row in table.rows)
{
sqlstr += "insert into " + table.tablename + "(";
foreach (datacolumn col1 in table.columns)
{
sqlstr += col1.columnname + ",";
}
sqlstr = sqlstr.substring(0, sqlstr.length - 1) + ") values (";
string tempsql = "";
string tempsql1 = "";
foreach (datacolumn col in table.columns)
{
tempsql1 = getvaluesql(row, col);
if (tempsql1.length > 0)
{
if (tempsql.length > 0) tempsql += ",";
tempsql += tempsql1;
}

}
if (tempsql.length == 0) continue;
sqlstr += tempsql + ")";
}
return sqlstr;
}
...全文
103 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
HarleyTung 2008-01-12
  • 打赏
  • 举报
回复
http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

去这里转
HarleyTung 2008-01-12
  • 打赏
  • 举报
回复
Public Shared Function getinsertsql(ByVal table As datatable) As String
Dim sqlstr As String = ""
For Each row As datarow In table.rows
sqlstr += "insert into " + table.tablename + "("
For Each col1 As datacolumn In table.columns
sqlstr += col1.columnname + ","
Next
sqlstr = sqlstr.substring(0, sqlstr.length - 1) + ") values ("
Dim tempsql As String = ""
Dim tempsql1 As String = ""
For Each col As datacolumn In table.columns
tempsql1 = getvaluesql(row, col)
If tempsql1.length > 0 Then
If tempsql.length > 0 Then
tempsql += ","
End If
tempsql += tempsql1

End If
Next
If tempsql.length = 0 Then
Continue For
End If
sqlstr += tempsql + ")"
Next
Return sqlstr
End Function
kbryant 2008-01-12
  • 打赏
  • 举报
回复
Public Shared Function GetInsertSql(ByVal table As DataTable) As String
Dim sqlstr As String = ""
For Each row As DataRow In table.Rows
sqlstr += "insert into " + table.TableName + "("
For Each col1 As DataColumn In table.Columns
sqlstr += col1.ColumnName + ","
Next
sqlstr = sqlstr.TrimEnd(","c) + ") values ("
Dim tempsql = ""
Dim tempsql1 = ""
For Each col As DataColumn In table.Columns
tempsql1 = GetValueSql(row, col)
If Not String.IsNullOrEmpty(tempsql1) Then
If tempsql.Length > 0 Then
tempsql += ","
End If
tempsql += tempsql1
End If
If tempsql.Length = 0 Then Continue
sqlstr += tempsql + ")"
Next
Return sqlstr
Next
End Function

hs_lijiadi 2008-01-12
  • 打赏
  • 举报
回复

Public Shared Function getinsertsql(ByVal table As datatable) As String
Dim sqlstr As String = ""
For Each row As datarow In table.rows
sqlstr += "insert into " + table.tablename + "("
For Each col1 As datacolumn In table.columns
sqlstr += col1.columnname + ","
Next
sqlstr = sqlstr.substring(0, sqlstr.length - 1) + ") values ("
Dim tempsql As String = ""
Dim tempsql1 As String = ""
For Each col As datacolumn In table.columns
tempsql1 = getvaluesql(row, col)
If tempsql1.length > 0 Then
If tempsql.length > 0 Then
tempsql += ","
End If
tempsql += tempsql1

End If
Next
If tempsql.length = 0 Then
Continue For
End If
sqlstr += tempsql + ")"
Next
Return sqlstr
End Function
zzxctk 2008-01-12
  • 打赏
  • 举报
回复
去下载个工具就可以了
地址是:
http://arimacn.com/soft/sort031/sort0172/down-31101.html
yangjianpro 2008-01-12
  • 打赏
  • 举报
回复
http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx
建议楼主看看 对你有关很有帮助
机器人 2008-01-11
  • 打赏
  • 举报
回复

Public Shared Function GetInsertSql(ByVal table As DataTable) As String
Dim sqlstr As String = ""
For Each row As DataRow In table.Rows
sqlstr += "insert into " + table.TableName + "("
For Each col1 As DataColumn In table.Columns
sqlstr += col1.ColumnName + ","
Next
sqlstr = sqlstr.TrimEnd(","c) + ") values ("
Dim tempsql = ""
Dim tempsql1 = ""
For Each col As DataColumn In table.Columns
tempsql1 = GetValueSql(row, col)
If Not String.IsNullOrEmpty(tempsql1) Then
If tempsql.Length > 0 Then
tempsql += ","
End If
tempsql += tempsql1
End If
If tempsql.Length = 0 Then Continue
sqlstr += tempsql + ")"
Next
Return sqlstr
Next
End Function

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧