Results 1 to 8 of 8

Thread: updating code

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    4

    updating code

    I have been assigned the task of updating some code which was written in an older version of vb. I am unfamiliar with the code and havent programmed in vb in quite a while.

    This function is giving me a syntax error. How would you suggest to fix this function?

    Code:
     Public Function bindthissql_ODBC(ByVal fds As Object, ByVal fsql As Object) As Object
                New OdbcDataAdapter(StringType.FromObject(fsql), Me.dbconn).Fill(DirectCast(fds, DataSet), "Thedata")
                Return New DataView(DirectCast(LateBinding.LateGet(fds, Nothing, "Tables", New Object() { "Thedata" }, Nothing, Nothing), DataTable))
            End Function

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: updating code

    Is that code from a VB6 project upgraded to VB.NET? What's the error message?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    4

    Re: updating code

    I am thinking originally it may have been vb6. I have just taken over this project so i am unaware of what has been done beforehand. The only error msg VS 2008 gives me is Syntax error.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: updating code

    When you build it or when you run it?

    My suggestion would be to rewrite that function yourself.

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    4

    Re: updating code

    When i try to run through VS in debug mode. I am not familliar with the code used in this and am lost in rewriting the function. If someone can understand what is happening here and do a quick rewrite it would be greatly appreciated.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: updating code

    When you get rid of all the late binding the method is rather simple. It takes a DataSet and a String containing an SQL query, then populates a DataTable in the DataSet and returns a new DataView of that table. I'd suggest you write a method from scratch that does that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    4

    Re: updating code

    This is what i have come up with. It shows no errors in VS but i have not tested it in tha actual ap yet. does this look correct?

    Code:
    Public Function bindthissql_SQL(ByVal fds As Object, ByVal fsql As Object) As Object
                Dim MyAdapter As New SqlDataAdapter(StringType.FromObject(fsql), Me.dbconn3)
                MyAdapter.Fill(DirectCast(fds, DataSet), "Thedata")
                Return New DataView(DirectCast(LateBinding.LateGet(fds, Nothing, "Tables", New Object() { "Thedata" }, Nothing, Nothing), DataTable))
            End Function

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: updating code

    I said get rid of all the late binding. If the values passed in are a particular type then declare them so. If the value returned is a particular type then declare it so. Then there's no need for casting or any of that other silliness.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width