Answered by:
how to send parameters array in function....

Question
-
User-1452537652 posted
hello everyone,
i am using XML as database, so updating or inserting diffrent XML's currently i am manage a seprate class for seprate XML file, this process consuming my lot of time,
i want to create a genrelize class. currently according to the XML need i am sending two, three, four or five parameter in my function.
now i want to send array of the parameter to my function, so becoz of this thing i could mange all of my functions via a single class...
i am sending u the example what currently i use now...
Public Function Update(ByVal Item_ID As Long, ByVal ProductName As String, ByVal Price As Long, ByVal Path As String) As Long
Try
Dim ds As New DataSet
ds.ReadXml(Path)
Dim dr As DataRow
dr = ds.Tables(0).NewRow
Dim a As Integer
Dim b As Integer
For b = 0 To ds.Tables(0).Rows.Count - 1
If Item_ID = ds.Tables(0).Rows(b)("ItemID") Then
ds.Tables(0).Rows(b)(0) = Item_ID
ds.Tables(0).Rows(b)(1) = ProductName
ds.Tables(0).Rows(b)(2) = Price
ds.WriteXml(Path, XmlWriteMode.WriteSchema)
End If
Next
Return 1
Catch ex As Exception
Return 0
End Try
End Function
instead of these itemid, productname, price i want to send an array of string parameters.....
some one help me out....
thanx and regards
Inderjeet Singh
Saturday, July 17, 2010 1:58 PM
Answers
-
User1224194097 posted
you can do this
Public Sub GetParameterValues(ByVal ParamArray array As Object()) End Sub
you can call that method as
GetParameterValues("a", "b", "b", 1234)
you can pass any object in that array as we declared as object
you have to cast it to right Type when you are reading the value from the array.
I recommend using String array.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, July 17, 2010 2:45 PM
All replies
-
User1224194097 posted
you can do this
Public Sub GetParameterValues(ByVal ParamArray array As Object()) End Sub
you can call that method as
GetParameterValues("a", "b", "b", 1234)
you can pass any object in that array as we declared as object
you have to cast it to right Type when you are reading the value from the array.
I recommend using String array.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, July 17, 2010 2:45 PM -
User-1452537652 posted
thanx a ton sansan,
you make my day,
acctualy i am using XML for display data at client side for increasing the performance of wbsite,
for this i am genrating an XML file for each table, what u think it is the right path, gerating XML file for each table or can u suggest me any better solution,
or if u know some tuotorial regarding data fatching(like TSQL Queries) from XML rather than ds.readxml i would be thank full to u....
thanx a ton once again.....
Best Regards
Inderjeet Singh Sethi
Saturday, July 17, 2010 5:03 PM