Question I cant add data into my sqldatabase

rocks_lp

Member
Joined
Dec 16, 2008
Messages
15
Programming Experience
Beginner
i amusing visual studio 2005.
i have initialized my connection in a module.
conn is the name of my connection

this is the Code

VB.NET:
Expand Collapse Copy
Public Class frmCreditNoteRequest
    Dim adapter As SqlDataAdapter
    Dim cmd As SqlCommand
    Dim ds As New DataSet

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Dim test As Boolean
        Dim sql As String
        sql = "INSERT INTO CreditNoteDetails (RequestedDate,CusId,Details,RequestedAmount) VALUES ('11-10-2008',2,'test',3000.00);"

        conn.Open()

        MsgBox("conection has open")

        test = conn.State   'to check the connection state

        MsgBox(test)


        cmd = New SqlCommand(sql, conn)

        conn.Close()

        adapter = New SqlDataAdapter

        adapter.InsertCommand = cmd

        MsgBox("You have successflly updated")

    End Sub
End Class


What is wrong in this coding plz help meeeeeeeeeeeeeeeee:mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad:
 
Back
Top