);
locConnToPlan.getWallDataFromPlan();
}
--------------------------------------------------------------------------------------------------------------------------------
*** This is the code from the seperate class for the odbc connection:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Data.Odbc;
using
System.Windows.Forms;
namespace
ArchiInfo
{
public class odbcConnect
{
public string connectionString = "";
public OdbcConnection loadPlan;
private OdbcDataReader sqlReader;
private OdbcCommand sqlCommand;
private string errString = "";
public Char[,] wall_ID = new Char[100,1];
public Char[,] wall_USERID = new Char[100, 1];
public Double[,] wall_LENGTH_SIDE_A = new Double[100, 1];
public Double[,] wall_LENGTH_SIDE_B = new Double[100, 1];
public Double[,] wall_SURFACE_SIDE_A = new Double[100, 1];
public Double[,] wall_SURFACE_SIDE_B = new Double[100, 1];
public Double[,] wall_SURFACE_SIDE_C = new Double[100, 1];
public Double[,] wall_CENTER_LENGTH = new Double[100, 1];
public void connectToPlanFile(string planDirStr, string libDirString)
{
string connString = "DRIVER={ArchiCAD 11 Project ODBC Driver}; PLANFILE=" + planDirStr + "; LIBRARIES=" + libDirString + "";
loadPlan =
new OdbcConnection(connString);
try
{
loadPlan.Open();
}
catch(OdbcException ex)
{
errString =
"Exception Handled: " + ex.Message;
MessageBox.Show(errString);
return;
}
}
public void getWallDataFromPlan()
{
string sqlQuery = "SELECT id, userid, length_on_sidea, length_on_sideb, surface_on_sidea, surface_on_sideb, surface_on_sidec, center_length FROM walls";
sqlCommand =
new OdbcCommand(sqlQuery, loadPlan);
sqlCommand.CommandText = sqlQuery;
try
{
sqlReader = sqlCommand.ExecuteReader();
}
catch (OdbcException ex)
{
errString =
"Exception Handled: " + ex.Message;
MessageBox.Show(errString);
return;
}
try
{
int rowCounter = 0;
while (sqlReader.Read())
{
wall_ID[rowCounter, 0] = sqlReader.GetChar(0);
wall_USERID[rowCounter, 0] = sqlReader.GetChar(1);
wall_LENGTH_SIDE_A[rowCounter, 0] = sqlReader.GetDouble(2);
wall_LENGTH_SIDE_B[rowCounter, 0] = sqlReader.GetDouble(3);
wall_SURFACE_SIDE_A[rowCounter, 0] = sqlReader.GetDouble(4);
wall_SURFACE_SIDE_B[rowCounter, 0] = sqlReader.GetDouble(5);
wall_SURFACE_SIDE_C[rowCounter, 0] = sqlReader.GetDouble(6);
wall_CENTER_LENGTH[rowCounter, 0] = sqlReader.GetDouble(7);
rowCounter++;
}
}
catch (OdbcException ex)
{
errString =
"Exception Handled: " + ex.Message;
MessageBox.Show(errString);
return;
}
finally
{
sqlReader.Close();
sqlReader.Dispose();
sqlCommand.Dispose();
loadPlan.Close();
loadPlan.Dispose();
}
}
}
}
--------------------------------------------------------------------------------------------------------
The errors occur when the code gets throug to loadPlan.Close();
Any help to get this resolved would be much apreciated as I seem to be going around in circles.
Thanks