Silverlight / WPF - Insert from table to table selected line only

Asked By David on 11-Jul-11 12:25 PM
  Hi All

 I have had great help from Pete Rainbow solving my Enter/Tab key problem on XAML forms so again I am stuck on 
 Insert from table to table selected line only and I dont seem to be getting anywhere.
 Is it possible for anyone to look at my programme and point me in the right direction on how to call/code the add new item from tableadapter I am lost

pete rainbow replied to David on 11-Jul-11 04:19 PM
paste the code up or attach and we'll have a go :-)
pete rainbow replied to David on 11-Jul-11 04:20 PM
BTw. Thanks for the plug...wonder if get any points for that ;-)
David replied to pete rainbow on 12-Jul-11 09:59 AM
 Hi Pete thanks for the reply I have tried to load the file onto this page but It must be too big even when zipped.
 I dont know if I am allowed to send it to you by e-mail but if so my e-mail is
pete rainbow replied to David on 12-Jul-11 10:31 AM
how about just pasting the xaml and code behind of the form on here?
David replied to pete rainbow on 12-Jul-11 10:52 AM
 Hi Pete

Imports System.Data

Imports System.Configuration

Imports System.Data.OleDb

Imports System.Data.SqlClient

Imports System.Linq

Public Class Window12

Private COURSES_PLAYEDData As New CoursesPlayedDataSet

Private taCOURSES_PLAYED As New CoursesPlayedDataSetTableAdapters.COURSES_PLAYEDTableAdapter

Private taManager As New CoursesPlayedDataSetTableAdapters.TableAdapterManager

Private Placeholder As String

Private view As CollectionView

Public Sub New()

' This call is required by the Windows Form Designer.


Call connmethod()

' Add any initialization after the InitializeComponent() call.

End Sub

Public Sub connmethod()

End Sub

Private Sub COURSEDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles COURSEDataGridView.CellContentClick

End Sub

Private Sub Window12_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

'TODO: This line of code loads data into the 'CoursesPlayedDataSet.Coursesplayed ' table. You can move, or remove it, as needed.



End Sub

Function GetData(ByVal queryString As String) As DataSet

' Retrieve the connection string stored in the Web.config file.

Dim connectionString As String = ConfigurationManager.ConnectionStrings("WpfDataEntry.MySettings.VB_DAVE_1__mainConnectionString").ConnectionString

Dim ds As New DataSet()


' Connect to the database and run the query.

Dim connection As New SqlConnection(connectionString)

Dim adapter As New SqlDataAdapter(queryString, connection)

' Fill the DataSet.


Catch ex As Exception

' The connection failed. Display an error message.

MsgBox("Unable to connect to the database.")

End Try

Return ds

End Function

Private Sub BindingNavigatorAddNewItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click





Dim newWindow12 = New Window12


Dim newWindow3 = New Window3


End Sub

Private Sub COURSESPLAYEDBindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles COURSESPLAYEDBindingSource.CurrentChanged

End Sub

End Class

 This if the code behind which runs my Datgrid view to select a new course from Courses and put the selected line into
 It dosent work and I dont know how to code it to run or call  the insert command from the  CoursesPlayedDataset

 Thanks David

David replied to pete rainbow on 21-Jul-11 03:34 PM