claire_bicknell
Well-known member
- Joined
- Dec 10, 2008
- Messages
- 49
- Programming Experience
- Beginner
I am trying to implement a feedback form which allows users to leave comments.
This information then needs to be stored in an SQL Server Database.
This is the code i currently have:
The form loads up and i fill out the Username and comments and click the submit button (button2) and nothing happens. The message box doesn't even pops up.
Does anyone have an idea?
I am very very new to this so direct pointers would be extremely appreciated as I have been staring at this for hours and you guys seem to be my only hope.
Thanks
This information then needs to be stored in an SQL Server Database.
This is the code i currently have:
HTML:
Imports System
Imports System.Data.Sql
Imports System.Data.SqlClient
Public Class Leave_your_Comments
Dim con As New SqlConnection(strConnection)
Const strConnection As String = "Data Source=PC-CLAIRE;Initial Catalog=ShoppingCentre;Integrated Security=True"
Dim cn As New SqlConnection()
Dim CustomersDataSet As New DataSet()
Dim da As SqlDataAdapter
Dim dr As DataRow
Dim cmdBuilder As SqlCommandBuilder
Dim inc As Integer
Dim MaxRows As Integer
Private Sub Leave_your_Comments_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
da = New SqlDataAdapter("select * FROM dbo.Feedback", con)
da.Fill(CustomersDataSet, "ShoppingCentre")
MaxRows = CustomersDataSet.Tables("ShoppingCentre").Rows.Count()
inc = -1
con.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strSQL As String = "SELECT Username, Comments from Feedback'"
If inc <> -1 Then
Dim dsNewRow As DataRow
dsNewRow = CustomersDataSet.Tables("ShoppingCentre").NewRow()
dsNewRow.Item("Username") = TextBox3.Text
dsNewRow.Item("Comment") = TextBox4.Text
dsNewRow.Item("Date") = DateTimePicker1.Text
CustomersDataSet.Tables("Shopping Centre").Rows.Add(dsNewRow)
da.Update(CustomersDataSet, "dbo.Feedback")
MsgBox("New Record added to the Database")
Button2.Enabled = False
'btnAddNew.Enabled = True
' btnUpdate.Enabled = True
' btnDelete.Enabled = True
'Me.Hide()
'frmMainMenu.Visible = True
'My.Computer.Audio.Play("click.wav", AudioPlayMode.Background)
End If
End Sub
The form loads up and i fill out the Username and comments and click the submit button (button2) and nothing happens. The message box doesn't even pops up.
Does anyone have an idea?
I am very very new to this so direct pointers would be extremely appreciated as I have been staring at this for hours and you guys seem to be my only hope.
Thanks
Last edited: