|
Hi everyone,
I'm probably being dim here but here's my problem.
My main form opens a subform for a user to add notes, when they click save it does the following:
---------------------------Start Code -----------------------------------
Dim cmd As New SqlClient.SqlCommand()
With cmd
.Connection = New SqlClient.SqlConnection("Data Source=MYSSERVER;Initial Catalog=PGLCMS;Integrated Security=True")
.CommandType = CommandType.Text
.CommandText = "INSERT into Notes VALUES (" & Val(TextBox3.Text) & ",'" & Trim(TextBox2.Text) & "','" & TextBox1.Text & "','" & Date.Now & "')"
End With
cmd.Connection.Open() '< Open it before executing the query
cmd.ExecuteNonQuery()
cmd.Connection.Close() '< Close it after executing the query
cmd.Dispose()
-----------------------------------End Code------------------------------------------------------
This sticks the right record in the right place, then when I close the notes entering form I want my notes listbox to refresh itself and display new data. So I added the following code below the lot above:
-----------------------------------Start code------------------------------------------------------
Form1.NotesTableAdapter.Fill(Form1.PGLCMSDataSet.N otes)
If Form1.RadioButton1.Checked Then
Form1.NotesTableAdapter.FillBy(Form1.PGLCMSDataSet .Notes, Form1.ListBox1.ValueMember)
ElseIf Form1.RadioButton2.Checked Then
Form1.NotesTableAdapter.FillBy1(Form1.PGLCMSDataSe t.Notes, Val(Form1.CompanyIDTextBox.Text))
Else
Form1.NotesTableAdapter.FillBy1(Form1.PGLCMSDataSe t.Notes, Val(Form1.CompanyIDTextBox.Text))
End If
Form1.NotesBindingSource.ResetItem(Form1.NotesBind ingSource.Current)
Form1.ListBox2.DataSource = Form1.NotesBindingSource
Form1.listbox2.refresh()
-----------------------------------End Code------------------------------------------------------
Which does absolutely nothing, the new notes dont display until I use the binding navigator to move to the next record and back.
Any ideas?
|