Q: what is missing with this code?

Discussion in 'ASP .Net' started by =?Utf-8?B?SklNLkgu?=, Mar 1, 2005.

  1. Hello,
    Here is my code, first part of this code is adding a static record to an SQL
    table and working fine, second part should get the data from the parameter
    myDSDest and put into the same SQL table, I was thinking I would just used
    dataset as the parameter for myDA.Update but it does not seem working, what
    should I do?


    Private Sub ELiveConnSQL(ByVal ConnStrDest As String, ByVal sqlStrDest As
    String, ByVal myDSDest As DataSet)

    Dim myConn As SqlConnection = New SqlConnection(ConnStrDest)
    myConn.Open()
    Try
    Dim mySqlCommand As SqlCommand = New SqlCommand(sqlStrDest,
    myConn)

    Dim myDA As SqlDataAdapter = New SqlDataAdapter(mySqlCommand)
    Dim myCommandBuilder As SqlCommandBuilder = New
    SqlCommandBuilder(myDA)

    ' Show commands
    Response.Write(myCommandBuilder.GetInsertCommand().CommandText)

    ' /****** first part *****/
    Dim myDTSrc As DataTable = New DataTable
    myDA.Fill(myDTSrc)

    'Use Insert
    Dim myRowSrc As DataRow = myDTSrc.NewRow
    myRowSrc("PtID") = "PtID"
    myRowSrc("ADate") = "01/01/2005"
    myRowSrc("ATime") = "12:00"
    myRowSrc("PtName") = "PtName "
    myDTSrc.Rows.Add(myRowSrc)


    myDA.Update(myDTSrc)
    myDTSrc.AcceptChanges()

    ' /****** second part *****/
    Dim myDTDest As DataTable = New DataTable
    myDTDest = myDSDest.Tables(0)

    myDA.Update(myDTDest)

    Catch ex As Exception
    Response.Write(ex.Message)
    Finally
    myConn.Close()
    End Try
    End Sub

    Thanks,
    Jim.
    =?Utf-8?B?SklNLkgu?=, Mar 1, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. niko
    Replies:
    3
    Views:
    3,758
  2. Gary Herron
    Replies:
    2
    Views:
    664
    Bruno Desthuilliers
    Jul 4, 2006
  3. moonhk
    Replies:
    3
    Views:
    489
    moonhk
    Nov 8, 2006
  4. pamela fluente

    How to detect missing page or object from code

    pamela fluente, Aug 21, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    316
    pamela fluente
    Aug 21, 2007
  5. CKKwan

    Code behind page DLL missing?

    CKKwan, Jul 16, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    478
Loading...

Share This Page