|
-
May 26th, 2008, 07:33 PM
#1
Thread Starter
New Member
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
-
May 27th, 2008, 01:00 AM
#2
Re: updating code
Is that code from a VB6 project upgraded to VB.NET? What's the error message?
-
May 27th, 2008, 01:04 PM
#3
Thread Starter
New Member
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.
-
May 27th, 2008, 03:29 PM
#4
Re: updating code
When you build it or when you run it?
My suggestion would be to rewrite that function yourself.
-
May 27th, 2008, 03:51 PM
#5
Thread Starter
New Member
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.
-
May 27th, 2008, 05:16 PM
#6
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.
-
May 27th, 2008, 05:44 PM
#7
Thread Starter
New Member
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
-
May 27th, 2008, 05:52 PM
#8
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|