2 Replies - 401 Views - Last Post: 08 May 2013 - 11:13 AM Rate Topic: -----

#1 BennyL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-May 13

Save VB textbox in Database

Posted 08 May 2013 - 11:06 AM

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim Connection As SqlConnection
Dim mySqlCommand As SqlCommand As String
Connection.Open()

mySqlCommand.Connection = Connection
Try
mySqlCommand.CommandText = INSERT INTO BookReviewWebsite (Review) VALUES ('@Review)

Dim InsertCommand As SqlCommand = New SqlCommand
InsertCommand.Parameters.AddWithValue("@Review", TextBox5.Text)

mySqlCommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("Review could not be added!" & ex.Message)
Finally
If Connection.State = ConnectionState.Open Then
Connection.Close()
End If
End Try
End Sub
End Class

Is This A Good Question/Topic? 0
  • +

Replies To: Save VB textbox in Database

#2 C.Andrews  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 169
  • Joined: 18-October 12

Re: Save VB textbox in Database

Posted 08 May 2013 - 11:11 AM

Hi and welcome to the boards. Couple notes:

1. Please read the posting instructions at the top of the page when creating a new topic.
2. Make sure you're asking a specific question; while we can probably reason it out on our own in this case, you're much more likely to get help by asking a specific question.
3. This forum has many excellent tutorials that will help you get started on general coding problems, if you work through those and still find you're having trouble, refer to 1 and 2.
Was This Post Helpful? 0
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: Save VB textbox in Database

Posted 08 May 2013 - 11:13 AM

So any problems with that code that you're experiencing?

Please use code tags for posting your code in a more readable format. The instructions are watermarked in the editor.

It would appear that a problem exists by glancing a couple of lines.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1