Board index » Visual Studio » Name not declared Error
|
DanSchwartz
|
Name not declared Error
Visual Studio62
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.eDataSet Then If mDatabaseType = eDatabaseType.eODBC Then Dim objCmd As New Odbc.OdbcCommand(sql, oODBCConnection) objCmd.CommandType = CommandType.Text Dim objDA As New Odbc.OdbcDataAdapter(objCmd) objDA.Fill(objDS, strTable) mDataSetObj = objDS Else 'Create the Command Object Dim objCmd As New SqlClient.SqlCommand(sql, objSQLConn) objCmd.CommandType = CommandType.Text Dim objDA As New SqlClient.SqlDataAdapter(objCmd) objDA.Fill(objDS, strTable) mDataSetObj = objDS End If Else If mDatabaseType = eDatabaseType.eODBC Then Dim objCmd As New Odbc.OdbcCommand(sql, oODBCConnection) objCmd.CommandType = CommandType.Text Dim objDR As OdbcDataReader = objCmd.ExecuteReader Else Dim objCmd As New SqlClient.SqlCommand(sql, objSQLConn) objCmd.CommandType = CommandType.Text Dim objDR As SqlDataReader = objCmd.ExecuteReader 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.FieldCount - 1 strXml.Append(" " & objDR.GetName(intIndex) & "=""" _ & objDR.GetValue(intIndex) & """") Next strXml.Append("/>") End While blnNextResult = objDR.NextResult() If blnNextResult = True Then intCount += 1 End If End If Loop strXml.Append("</Root>") mReturnXML = strXml.ToString objDR.Close() End If End If - |
