About
Pricing
Community
Teams
Start Free Trial
Log in
itortu
asked on
5/30/2007
assign dataset row value to function
i got just one more error in my program (well that is what i think)
i have this function:
Public Function GetStateByGeo(ByVal strGeo$) As DataSet
then i try to assign the dataset value to the function like this:
If (Not IsNothing(ds)) Then
If (ds.Tables(0).Rows.Count > 0) Then
GetStateByGeo = ds.Tables(0).Rows(0).ToStr
ing
End If
End If
but i get error:
Value of type 'System.Data.DataRow' cannot be converted to 'System.Data.DataSet'.
how can the data set (recordset) can be assigned to the function ?
Visual Basic.NET
.NET Programming
Programming Languages-Other
8
3
Last Comment
Bob Learned
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Bob Learned
5/30/2007
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
divinewind80
5/30/2007
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CmdoProg2
5/30/2007
Do you want to return one row of the table or the whole table in the return dataset?
itortu
5/30/2007
ASKER
than yo for asking, i want to return one row fo the table
itortu
5/30/2007
ASKER
i tried your suggestion this way:
Public Function GetStateByGeo(ByVal strGeo$) As DataSet
Dim intGeoState As Integer
Dim strSQL As String = ""
Dim strFlag As String = ""
Dim ds As DataSet = Nothing
dim dr as DataRow
Try
intGeoState = CInt(Mid(strGeo, 1, 2))
strFlag = GetTableFlag("LOCSTATE")
strSQL = "SELECT * FROM LOCSTATE" & strFlag & " WHERE locgeostate = " & intGeoState
ds = m_objSQLServerSQLDATA.GetD
ataSet(str
SQL, CommandType.Text, 0)
If (Not IsNothing(ds)) AndAlso ds.Tables(0).Rows.Count > 0 Then
Return ds.Tables(0).Rows(0).ToStr
ing
End If
Catch ex As Exception
Finally
ds = Nothing
End Try
Return ds
End Function
this is how the function gets called from another function:
ds = o_data.GetStateByGeo(strGe
o)
now i get the error:
Value of type 'String' cannot be converted to 'System.Data.DataSet'.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SOLUTION
CmdoProg2
5/30/2007
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
itortu
5/30/2007
ASKER
sorry this line
Public Function GetStateByGeo(ByVal strGeo$) As DataSet
is actually
Public Function GetStateByGeo(ByVal strGeo$) As string
the error:
Value of type 'String' cannot be converted to 'System.Data.DataSet'.
is given now by this part:
ds = o_data.GetStateByGeo(strGe
o)
Bob Learned
5/30/2007
Me.TextBox1.Text = o_Data.GetStateByGeo(strGe
o)
Bob