G
Guest
I have an ODBC data source that has EXTREMELY limited SQL functionality that
I want to expose via a web service.
For example, I need to SELECT DISTINCT and teh ODBC client does not support
the DISTINCT keyword. So, in the web service I am forced to retrieve ALL
records that match the WHERE clause.
Here is the relevant code I am using to retrieve the ODBC data and create
the dataset within the web service.
OdbcConnection oConn = new OdbcConnection();
DataSet ds = new DataSet();
DataTable jobsTable = new DataTable();
OdbcCommand cmd = new OdbcCommand();
//Define JobNos table in Dataset
jobsTable.TableName = "JobNos";
ds.Tables.Add(jobsTable);
jobsTable.Columns.Add("JobNo", typeof(string));
string szSQL;
szSQL = "SELECT Job_No,Job_Cnct_No FROM JC_JOBM WHERE JOB_STATUS = 'O'
ORDER BY Job_No";
oConn.ConnectionString = "DSN=" + pszDSN;
cmd.Connection = oConn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
oConn.Open();
OdbcDataReader dr = cmd.ExecuteReader();
string szJobNo;
string szCnctNo;
string szTemp;
while (dr.Read())
{
szJobNo = dr[0].ToString();
szTemp = szJobNo.Substring(2, szJobNo.Length - 2);
jobsTable.Rows.Add(new object[] { szTemp });
}
return ds;
Note that I have removed some code within the loop that formats the job
number before it is added to the DS.
The problem is, I do not want to add the job number to the DS if it is
already there. However, as the list of job numbers grows, the time it takes
to check for each job number in the DS would get to be too long.
Is there a way to filter or order or something this DS after it is created
and populated?
Something like:
SELECT DISTINCT JobNo FROM ds?
Any ideas?
Thanks,
John
I want to expose via a web service.
For example, I need to SELECT DISTINCT and teh ODBC client does not support
the DISTINCT keyword. So, in the web service I am forced to retrieve ALL
records that match the WHERE clause.
Here is the relevant code I am using to retrieve the ODBC data and create
the dataset within the web service.
OdbcConnection oConn = new OdbcConnection();
DataSet ds = new DataSet();
DataTable jobsTable = new DataTable();
OdbcCommand cmd = new OdbcCommand();
//Define JobNos table in Dataset
jobsTable.TableName = "JobNos";
ds.Tables.Add(jobsTable);
jobsTable.Columns.Add("JobNo", typeof(string));
string szSQL;
szSQL = "SELECT Job_No,Job_Cnct_No FROM JC_JOBM WHERE JOB_STATUS = 'O'
ORDER BY Job_No";
oConn.ConnectionString = "DSN=" + pszDSN;
cmd.Connection = oConn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
oConn.Open();
OdbcDataReader dr = cmd.ExecuteReader();
string szJobNo;
string szCnctNo;
string szTemp;
while (dr.Read())
{
szJobNo = dr[0].ToString();
szTemp = szJobNo.Substring(2, szJobNo.Length - 2);
jobsTable.Rows.Add(new object[] { szTemp });
}
return ds;
Note that I have removed some code within the loop that formats the job
number before it is added to the DS.
The problem is, I do not want to add the job number to the DS if it is
already there. However, as the list of job numbers grows, the time it takes
to check for each job number in the DS would get to be too long.
Is there a way to filter or order or something this DS after it is created
and populated?
Something like:
SELECT DISTINCT JobNo FROM ds?
Any ideas?
Thanks,
John