asp.net将数据集插入其他数据库

时间:2013-02-07 15:24:55

标签: asp.net dataset

我想将数据集内置于其他数据表

中的同一数据库中

这是我的代码

Dim Conn As SqlConnection = New SqlConnection("server=localhost;database=MSDSS;Integrated Security=True")
    Dim urltext = "Select JournalName, IndexDB, Lang, Category From SJournal where JournalName is not null" + " And IndexDB='" & indexdb & "' And Lang='" & lang & "' And [Impact Factor] Between " & ImpactFactorBegin & " And " & ImpactFactorEnd
    Dim Ad As SqlDataAdapter = New SqlDataAdapter(urltext, Conn)
    Dim D As DataSet = New DataSet()

    Ad.Fill(D, "SJ")
    D.Tables(0).Columns.Add(New DataColumn("STV"))
    Dim journallist() As String = journalname.Split("()")
    For i As Integer = 0 To D.Tables(0).Rows.Count - 1 Step 1
        D.Tables(0).Rows(i)("STV") = GetSimilarityWith(D.Tables(0).Rows(i).Item(0).ToString, journalname)

    Next i

如何将此数据放入其他数据库?

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

Dim Conn As SqlConnection = New SqlConnection("server=localhost;database=MSDSS;Integrated Security=True")
Dim Conn2 As SqlConnection = New SqlConnection("server=OTHER DB;database=MSDSS;Integrated Security=True")
Dim urltext = "Select JournalName, IndexDB, Lang, Category From SJournal where JournalName is not null" + " And IndexDB='" & indexdb & "' And Lang='" & lang & "' And [Impact Factor] Between " & ImpactFactorBegin & " And " & ImpactFactorEnd
Dim Ad As SqlDataAdapter = New SqlDataAdapter(urltext, Conn)
Dim Ad2 As SqlDataAdapter = New SqlDataAdapter(urltext, Conn2)
Dim D As DataSet = New DataSet()

Ad.Fill(D, "SJ")
D.Tables(0).Columns.Add(New DataColumn("STV"))
Dim journallist() As String = journalname.Split("()")
For i As Integer = 0 To D.Tables(0).Rows.Count - 1 Step 1
    D.Tables(0).Rows(i)("STV") = GetSimilarityWith(D.Tables(0).Rows(i).Item(0).ToString, journalname)
Next i

Ad2.Fill(D, "SJ")