|
-
Dec 1st, 2004, 10:17 AM
#1
Thread Starter
Lively Member
errors with System.Data.Datarow
Hi, this is my code:
Dim datarow1 as DataRow
datarow1 = DataSchema1.Clientes.NewRow()
datarow1 = DataSchema1.Clientes.Select("IdCliente=IdClienLabel.Text)
NombreCliente.Text = datarow1("Nombre").ToString
And the DataSchem....select... line gets underlined in blue and it says that "a value of type '1-matrix dimensional of System.Data.DataRow' can't be converted to '2' "
Any clue? Thanks heaps!!
-
Dec 1st, 2004, 11:05 AM
#2
Addicted Member
The Select() method of the datatable returns a 1-dimensional array of type DataRow. The following example should give you a guide.
VB Code:
Dim rows() As DataRow
rows = DataSchema1.Clientes.Select("IdCliente = IdClienLabel.Text")
If (Not rows Is Nothing) Then
Text1.Text = rows(0).Item("Nombre").ToString
End If
-
Dec 1st, 2004, 11:05 AM
#3
Addicted Member
The Select() method of the datatable returns a 1-dimensional array of type DataRow. The following example should give you a guide.
VB Code:
Dim rows() As DataRow
rows = DataSchema1.Clientes.Select("IdCliente = IdClienLabel.Text")
If (Not rows Is Nothing) Then
Text1.Text = rows(0).Item("Nombre").ToString
End If
-
Dec 1st, 2004, 11:49 AM
#4
In case you post the same thread twice, just edit one of them and mark as [Please Delete]. It confuses us simple folk.
-
Dec 1st, 2004, 12:51 PM
#5
Thread Starter
Lively Member
Hey thanks for your help,
I'm still getting an error, now what if get is from the line that goes ...rows(0)... it says the index is out of matrix range.
What I'm trying to do is to select rows of data applying a filter from my dataset, I thought just defining a variable as datarow and having it contain the results from select() would be enough but I guess it isn't.
Thanks again.
-
Dec 1st, 2004, 01:23 PM
#6
Addicted Member
If the number of elements in the array [datarow array] is less than one, it should return nothing -- I think.
May be you should try
VB Code:
If (rows.Length > 0) Then
Text1.Text = rows(0).Item("Nombre").ToString
End If
-
Dec 1st, 2004, 01:32 PM
#7
Thread Starter
Lively Member
Ok yeah, that was the problem the select() method was giving me no results. But now I've tried setting it this way:
Dataschema1.Clientes.Select("IdCliente=4") and it still gives me no results back. And I know there is a Client whos ID is 4. In the table IdCliente is defined as integer.
How come it isn't retrieving the data correctly.?
Thanks lots!!!
-
Dec 1st, 2004, 01:45 PM
#8
Thread Starter
Lively Member
Ok, got it! It is because I had to do Dataschema1.ReadXml()
Do I have to read the xml everytime I run a form? Can't I do it at the beginning of the application once for all?
Thanks again
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
|