Hi,
I am getting "Name objDR is not declared" error. I am declaring objDR in
the if
then else section. How do I over come this issue.
Thanks for the help.
Dim objDS As New DataSet("Root")
Dim strXml As New StringBuilder
Dim strTable As String = "row"
Dim objRetMetaData As New DataSet
Dim blnNextResult As Boolean = True
Dim intCount As Integer = 0
Dim intIndex As Integer = 0
If OpenConnection( ) Then
If retType = eReturnType.eDa taSet Then
If mDatabaseType = eDatabaseType.e ODBC Then
Dim objCmd As New Odbc.OdbcComman d(sql,
oODBCConnection )
objCmd.CommandT ype = CommandType.Tex t
Dim objDA As New Odbc.OdbcDataAd apter(objCmd)
objDA.Fill(objD S, strTable)
mDataSetObj = objDS
Else
'Create the Command Object
Dim objCmd As New SqlClient.SqlCo mmand(sql,
objSQLConn)
objCmd.CommandT ype = CommandType.Tex t
Dim objDA As New SqlClient.SqlDa taAdapter(objCm d)
objDA.Fill(objD S, strTable)
mDataSetObj = objDS
End If
Else
If mDatabaseType = eDatabaseType.e ODBC Then
Dim objCmd As New Odbc.OdbcComman d(sql,
oODBCConnection )
objCmd.CommandT ype = CommandType.Tex t
Dim objDR As OdbcDataReader = objCmd.ExecuteR eader
Else
Dim objCmd As New SqlClient.SqlCo mmand(sql,
objSQLConn)
objCmd.CommandT ype = CommandType.Tex t
Dim objDR As SqlDataReader = objCmd.ExecuteR eader
End If
strXml.Append(" <Root>")
Do Until blnNextResult = False
If objDR.HasRows() = False Then
Exit Do
Else
While objDR.Read()
strXml.Append(" <row")
For intIndex = 0 To objDR.FieldCoun t - 1
strXml.Append(" " &
objDR.GetName(i ntIndex) & "=""" _
& objDR.GetValue( intIndex) & """")
Next
strXml.Append("/>")
End While
blnNextResult = objDR.NextResul t()
If blnNextResult = True Then
intCount += 1
End If
End If
Loop
strXml.Append(" </Root>")
mReturnXML = strXml.ToString
objDR.Close()
End If
End If
I am getting "Name objDR is not declared" error. I am declaring objDR in
the if
then else section. How do I over come this issue.
Thanks for the help.
Dim objDS As New DataSet("Root")
Dim strXml As New StringBuilder
Dim strTable As String = "row"
Dim objRetMetaData As New DataSet
Dim blnNextResult As Boolean = True
Dim intCount As Integer = 0
Dim intIndex As Integer = 0
If OpenConnection( ) Then
If retType = eReturnType.eDa taSet Then
If mDatabaseType = eDatabaseType.e ODBC Then
Dim objCmd As New Odbc.OdbcComman d(sql,
oODBCConnection )
objCmd.CommandT ype = CommandType.Tex t
Dim objDA As New Odbc.OdbcDataAd apter(objCmd)
objDA.Fill(objD S, strTable)
mDataSetObj = objDS
Else
'Create the Command Object
Dim objCmd As New SqlClient.SqlCo mmand(sql,
objSQLConn)
objCmd.CommandT ype = CommandType.Tex t
Dim objDA As New SqlClient.SqlDa taAdapter(objCm d)
objDA.Fill(objD S, strTable)
mDataSetObj = objDS
End If
Else
If mDatabaseType = eDatabaseType.e ODBC Then
Dim objCmd As New Odbc.OdbcComman d(sql,
oODBCConnection )
objCmd.CommandT ype = CommandType.Tex t
Dim objDR As OdbcDataReader = objCmd.ExecuteR eader
Else
Dim objCmd As New SqlClient.SqlCo mmand(sql,
objSQLConn)
objCmd.CommandT ype = CommandType.Tex t
Dim objDR As SqlDataReader = objCmd.ExecuteR eader
End If
strXml.Append(" <Root>")
Do Until blnNextResult = False
If objDR.HasRows() = False Then
Exit Do
Else
While objDR.Read()
strXml.Append(" <row")
For intIndex = 0 To objDR.FieldCoun t - 1
strXml.Append(" " &
objDR.GetName(i ntIndex) & "=""" _
& objDR.GetValue( intIndex) & """")
Next
strXml.Append("/>")
End While
blnNextResult = objDR.NextResul t()
If blnNextResult = True Then
intCount += 1
End If
End If
Loop
strXml.Append(" </Root>")
mReturnXML = strXml.ToString
objDR.Close()
End If
End If
Comment