VB.net将特定列中的数据集值检索为字符串

时间:2014-09-23 16:46:57

标签: vb.net

我需要将所选数据库的结构复制到新数据库。这怎么可能?我无法检索DataSet值。我需要使用此值来检索与数据库关联的表名。这是我的代码。

cmd.CommandText = "create database " & txtCustId.Text & "AAA"
cmd.ExecuteNonQuery()
Dim dtadapt As New SqlDataAdapter("select table_name from " & name & ".INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'BASE TABLE'", comm_con)
Dim dtset As New DataSet
dtadapt.Fill(dtset)
Dim dttb As DataTable = dtset.Tables(0)
'Dim row As Integer = 1
Dim arrS As String = ""
while dttb.Rows.Count > 0 
    'arrS =Convert.ToString(dtset.Tables[i].Rows[0]["table_name"])
    arrS = dttb("table_name").ToString
    cmd.CommandText = " SELECT * INTO " & txtCustId.Text & "AAA.dbo." & arrS & " FROM " & name & ".dbo." & arrS & " where 1=1"

    cmd.ExecuteNonQuery()
    'MessageBox.Show("done")
End while

0 个答案:

没有答案