[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Insert Textbox values to database

Hi Experts,

I need to collect the value of textboxes on a form and send those values to a database using a button click (SaveAddOffenses).  I have the following code so far:

    Private Sub SaveAddOffenses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAddOffenses.Click
        Dim MyConnection As SqlConnection = New SqlConnection()
        MyConnection.ConnectionString = _
        "Network Library=DBMSSOCN;" & _
        "Data Source=itadmin4,1433;" & _
        "Initial Catalog=Reporting;" & _
        "User ID=sa;" & _

        Dim mycommand As SqlCommand
        Dim dr As SqlDataReader
            mycommand = New SqlCommand("Select * from Incidents", MyConnection)
            dr = mycommand.ExecuteReader()
        Catch ex As Exception
        End Try

    End Sub
End Class

I know I am close but I cannot figure it out.  Thanx in advance.  

P.s.  I am using VB 2005 accessing sql 2005 database
1 Solution

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now