Hi
I have a project that generates three management charts from stored procedures using the UltraChart control. I have followed the example in the online documentation "How to Create an Object Data Source Using Stored Procedures" however I have two questions
1. Is there a version of this code in VB.NET?
2. My stored procedures have two parameters @start_date and @end_date. How do I pass these parameters to the ObjectDataSource?
Any help greatly appreciated.
Regards
James O'DohertySolution and Database ArchitectLandesbank Berlin AG
Hi James,
Let me know if you have any further questions on this matter?
Here is the version of that code converted to VB.NET:
Public Function GetProducts() As IEnumerable(Of Product) Dim products As List(Of Product) = New List(Of Product) Using conn = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("NORTHWIND").ConnectionString) conn.Open() Using cmd As New SqlCommand("ProductOrderedByPrice", conn) cmd.CommandType = System.Data.CommandType.StoredProcedure Using reader = cmd.ExecuteReader() While reader.Read() products.Add(New Product() With { _ .Code = CInt(reader("ProductID")), _ .Price = CDec(reader("UnitPrice")) _ }) End While End Using End Using End Using Return products End Function
As for passing parameters to the stored procedures, the SqlCommand class has a Parameters collection with which you can add your parameters. http://msdn.microsoft.com/en-us/library/yy6y35y8%28v=vs.71%29.aspx