DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Making VB.net 2003 SqlDataAdapter work in vb.net 2005

  1. #1
    Join Date
    Nov 2007
    Location
    Kansas
    Posts
    3

    Making VB.net 2003 SqlDataAdapter work in vb.net 2005

    Converted a project from 2003 to 2005 and regenerated the dataset in 2005 and now get !NullReferenceException was unhandled by user code {"Object reference not set to an instance of an object."} in me.sqldataadaper1.fill

    If Not Page.IsPostBack Then
    Me.Label1.Text = "Hello"
    Me.SqlDataAdapter1.Fill(Me.TealTeacher1, "teacher")
    Me.DataGrid1.DataBind()
    End If

    Me.TealTeacher1 is a dataset in the view component designer that was created from a SqlDataAdapter with a SqlConnection, these were created in 2003.

    How do I resolve this?

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    I don't see where you are creating the dataadapter.

  3. #3
    Join Date
    Nov 2007
    Location
    Kansas
    Posts
    3
    It is in the generated code in :
    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
    Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
    Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
    Me.TealTeacher1 = New TealTest.TealTeacher
    CType(Me.TealTeacher1, System.ComponentModel.ISupportInitialize).BeginInit()
    '
    'SqlDataAdapter1
    '
    Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
    Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "teacher", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ssn", "ssn"), New System.Data.Common.DataColumnMapping("last_name", "last_name"), New System.Data.Common.DataColumnMapping("first_name", "first_name"), New System.Data.Common.DataColumnMapping("mid_name", "mid_name")})})
    '
    'SqlSelectCommand1
    '
    Me.SqlSelectCommand1.CommandText = "SELECT ssn, last_name, first_name, mid_name, city, state" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "FROM dbo.te" & _
    "acher" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "WHERE (ssn < '000000055')"
    Me.SqlSelectCommand1.Connection = Me.SqlConnection1
    '
    'SqlConnection1
    '
    Me.SqlConnection1.ConnectionString = Global.TealTest.My.MySettings.Default.TealTestL
    Me.SqlConnection1.FireInfoMessageEventOnUserErrors = False
    '
    'TealTeacher1
    '
    Me.TealTeacher1.DataSetName = "TealTeacher"
    Me.TealTeacher1.Locale = New System.Globalization.CultureInfo("en-US")
    Me.TealTeacher1.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
    CType(Me.TealTeacher1, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub
    Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
    Protected WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
    Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
    Protected WithEvents TealTeacher1 As TealTest.TealTeacher

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs)
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region

  4. #4
    Join Date
    Nov 2007
    Location
    Kansas
    Posts
    3
    It appears to work if I call Page_Init(sender, e) in the page_load then all works as before so far.

    This is probably not the best way to do this, if there is a better way to fix please let me know.

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Well, if it is working, go with it.

Similar Threads

  1. Referencing VB 2005 dll in VB 2003
    By lucbrunet in forum .NET
    Replies: 5
    Last Post: 08-16-2006, 09:29 PM
  2. VS.Net 2003 to 2005 Questions
    By shstubbs in forum .NET
    Replies: 2
    Last Post: 04-04-2006, 12:06 PM
  3. Can VB.net work with Access 97 ?
    By psd in forum VB Classic
    Replies: 1
    Last Post: 10-19-2002, 04:52 PM
  4. Making RDS work in dev environment
    By Joe in forum Enterprise
    Replies: 0
    Last Post: 08-24-2001, 07:02 PM
  5. A moderate view.
    By Paul Mc in forum .NET
    Replies: 214
    Last Post: 06-01-2001, 07:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center