Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2006, 02:07 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataAdapter.Fill()

Hi,
I need help PLEASE.
I tried to pull information from two tables, the two tables have relationship of many to many and there is third table " relationship table" between the two tables.
So I connected to the database and I connection string works good, but when execution reaches this fragment of code "objdataAdapte.fil (objDataSet, "tableName")I get ERROR message that says
"An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll"

Dim objConnection As SqlConnection = New SqlConnection("seRver=(local);database=pubs;Integr ated Security=SSPI;user id=Oner;password=xxxxxxxxx;")
    Dim objDataAdapter As SqlDataAdapter = New SqlDataAdapter("SELECT authors_id, au_fname, au_lname, " & _
        "titles.title_id, title, price " & _
        "FROM authors " & _
        "JOIN titleauthor ON authors.au_id = titleauthor.au_id " & _
        "JOIN titles ON titleauthor.title_id = titles.title_id " & _
        "ORDER BY au_lname, au_fname", objConnection)
    Dim objDataSet As DataSet
    Dim objDataView As DataView
    Dim objCurrencyManager As CurrencyManager


THEN I CALL THIS CODE AT FORM LOAD EVENT
Private Sub FillDataSetAndView()
        'initialize the new Instance of the Dataset Object
        objDataSet = New DataSet()

        'Fill the DataSet with data

        objDataAdapter.Fill(objDataSet, "authors")


        'set the dataview Object to the DataSet object ....
        objDataView = New DataView(objDataSet.Tables("authors"))

        'Set the CurrencyManager object to the DataView
        objCurrencyManager = CType(Me.BindingContext(objDataView), CurrencyManager)

NOTE: I COPIED THIS CODE STRAIGHT FROM VB BOOK.
AND REMEMBER I AM PULLING THE INFORMATION FROM TWO TABLES BUT I'M POPULATING THE DATASET WITH ONE TABLE IS THAT BROBLEM?

THANKS AND ANY HELP IS REALLY APPRECIATED.

 
Old July 10th, 2006, 02:57 AM
Registered User
 
Join Date: Jun 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI,
Disregard that,
that was my fault for I misspelled a fieldName.
thanks alot any ways






Similar Threads
Thread Thread Starter Forum Replies Last Post
How many DataAdapter in a Form melvik ADO.NET 5 November 2nd, 2008 03:14 AM
update dataadapter karenai Visual Basic 2005 Basics 0 February 9th, 2008 10:46 PM
Dataadapter with parameter kau_shuk VS.NET 2002/2003 0 January 4th, 2007 02:43 AM
dataadapter --- dataset thas123 ASP.NET 2.0 Basics 0 December 13th, 2006 08:58 AM
DataAdapter.Update puzzle wirerider ASP.NET 2.0 Basics 1 August 1st, 2006 06:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.