defaultview when using junction table

intozz

New member
Joined
Mar 29, 2009
Messages
3
Programming Experience
Beginner
Hi, this is just a test try out i did. 3 datatables:-

tooling

toolingid
toolingname

cuttingtools

cuttingtoolsid
cuttingtool

toolingcuttingtools

cuttingtoolsid
toolingid

i have foreignkeys into the 1st 2 from third. the third table is needed because all the cuttingtools can fit in many of the different tooling i have. i have these stored procedures for querying:-

SELECT cuttingtool, cuttingtoolid
FROM cuttingtools
WHERE (cuttingtool = @cuttingtool)

SELECT tooling.toolingname, tooling.toolingid
FROM tooling INNER JOIN
toolingcuttingtools ON tooling.toolingid = toolingcuttingtools.toolingid INNER JOIN
cuttingtools ON toolingcuttingtools.cuttingtoolid = cuttingtools.cuttingtoolid
WHERE (cuttingtools.cuttingtool = @cuttingtool)

these work great. i have this code for firing both dgv's at the same time:-

Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByToolStripButton.Click
Try
Me.CuttingtoolsTableAdapter.FillBy(Me._1DataSet.cuttingtools, CuttingtoolToolStripTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
Try
Me.ToolingTableAdapter.FillBy(Me._1DataSet.tooling, CuttingtoolToolStripTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub

this way if i search a cuttingtool it pulls back all related tooling that can go with it. so my question is what if i dont want to search a cutting tool i just want highlight each record and have the tooling dgv bring back related tooling automatically.

i have this but i just get inner exception:-

Private dt As DataTable
Private dv As Data.DataView
Private ds As DataSet
Sub New()
InitializeComponent()
dt = New DataTable("toolingcuttingtools")
ds = New DataSet("_1")


dv = ds.Tables("toolingcuttingtools").DefaultView
dv.RowFilter = "cuttingID"
Me.CuttingtoolsDataGridView.DataSource = dv
Me.ToolingDataGridView.DataSource = dv
End Sub

but i get an exception:-

System.InvalidOperationException was unhandled
Message="An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object."
Source="WindowsApplication3"
StackTrace:
at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at WindowsApplication1.My.MyProject.MyForms.get_Form1()
at WindowsApplication1.My.MyApplication.OnCreateMainForm() in C:\Users\sql\Documents\Visual Studio 2008\Projects\WindowsApplication3\WindowsApplication3\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.NullReferenceException
Message="Object reference not set to an instance of an object."
Source="WindowsApplication3"
StackTrace:
at WindowsApplication1.Form1..ctor() in C:\Users\sql\Documents\Visual Studio 2008\Projects\WindowsApplication3\WindowsApplication3\Form1.vb:line 11
InnerException:

hope theres enough info here
 
Back
Top