weird DBASE IV data access

R

ray.bradbury9

Hello,

First of all, sorry because of my poor english.

I am having a weird problem that I don´t know how to solve. I am not
sure even if it is a problem within the OS or the .NET Framework. The
platform is a Tablet PC device running XP. AFAIK it has installed .NET
1.1 SP 1.

Depending on what device (Desktop PC or Tablet PC) a certain table (DBF
and MDX file) resides it shows DBNulls on certain columns (it seems
that all the Double fields are affected). I'm not if is a .NET issue,
because if I try to open the table using MS Access it behaves the same
way. If the file is looked in the Tablet PC it shows DBNull values
instead of the original table data. The table has values in that
fields, but it seems to have DBNulls (unless you copy the table to
other file).

If, in the Tablet PC, you execute an SQL update statement against the
table assigning the desired values to the table, the updated rows are
shown correctly (but all other fields remain as DBNull values).

Any help will be appreciated.
 
C

Cor Ligthert [MVP]

Ray,

Please don't excuse you for whatever. However show us *some* code. (The
essential parts and than no pseudo).

With only words we really cannot see what can be the problem form the
thousand of possibilities that there are.

Cor
 
R

ray.bradbury9

Sure,

provider is "OLEDB", tipoComando is "DATASET" and the connection string
is like "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=[pathToTheDbfFiles];Extended Properties=dBase
IV;Mode=ReadWrite;Persist Security Info=False"

No exception is thrown and the DataTable returned does not have the
real values the table has.

private void ejecutarSentenciaSQL(string sql, string strConn, string
provider, string tipoComando)
{
IDbConnection conn;
IDataAdapter da=null;
IDbCommand comm = null;
switch(provider.ToUpper())
{
case "OLEDB":
conn = new OleDbConnection(strConn);
if(tipoComando.ToUpper()=="DATASET")
{
da = new OleDbDataAdapter(sql,(OleDbConnection) conn);
}
else
{
comm = new OleDbCommand(sql,(OleDbConnection) conn);
}
break;
case "ODBC":
conn = new OdbcConnection(strConn);
if(tipoComando.ToUpper()=="DATASET")
{
da = new OdbcDataAdapter(sql,(OdbcConnection) conn);
}
else
{
comm = new OdbcCommand(sql,(OdbcConnection) conn);
}
break;
case "ORACLE":
conn = new OracleConnection(strConn);
if(tipoComando.ToUpper()=="DATASET")
{
da = new OracleDataAdapter(sql,(OracleConnection) conn);
}
else
{
comm = new OracleCommand(sql,(OracleConnection) conn);
}
break;
case "SQLSERVER":
conn = new SqlConnection(strConn);
if(tipoComando.ToUpper()=="DATASET")
{
da = new SqlDataAdapter(sql,(SqlConnection) conn);
}
else
{
comm = new SqlCommand(sql,(SqlConnection) conn);
}
break;
default:
throw new Exception("Tipo de proveedor desconocido!");
}
switch(tipoComando.ToUpper())
{
case "DATASET":
DataSet ds = new DataSet();
da.Fill(ds);
if(ds.Tables.Count==0)
{
MessageBox.Show("La sentencia DataSet no devuelve tablas!");
}
else
{
dgDatos.DataSource=ds.Tables[0];
}
break;
case "NONQUERY":
int rowsAffected = 0;
try
{
conn.Open();
rowsAffected=comm.ExecuteNonQuery();
MessageBox.Show("Rows Affected: " + rowsAffected.ToString());
}
catch(Exception exc)
{
tratarErrores(exc);
}
finally
{
try
{
if(conn.State==ConnectionState.Open)
{
conn.Close();
}
}
catch
{
}
}
break;
case "SCALAR":
object objRetorno = null;
try
{
conn.Open();
objRetorno=comm.ExecuteScalar();
MessageBox.Show("Tipo retorno: " +
objRetorno.GetType().ToString() + "\n Valor: " +
objRetorno.ToString());
}
catch(Exception exc)
{
tratarErrores(exc);
}
finally
{
try
{
if(conn.State==ConnectionState.Open)
{
conn.Close();
}
}
catch
{
}
}
break;
default:
throw new Exception("Tipo de Comando desconocido!");
}
}
 
R

ray.bradbury9

Cor,

Thanks for your help, but I am not lucky.

The application is already in production. I only make new changes to
the app. The source code has been working fine for half a year without
problems. I think it is not the way of accesing, but the OS itself.
Perhaps the .NET assemblies or the Windows XP Tablet Pc edition.

Correct me if I am wrong but, if it is the VB.NET code, why the MS
Access does also show DBNull values?

The app uses an OleDbConnection with the connectionstring
"Provider=Microsoft.Jet.OLEDB.4.0..." when I noticed it was not getting
results from a certain datatable from a certain Tablet PC, I used the
code above to take a look at the table. In the Tablet PC it seems to be
Null values in certain fields (double fields). The same code in a
desktop PC worked fine (no null values).

the www.connectionstrings.com is a great site I have visited many
times, but I cannot change the way the app access the database because
of the amount of time required to testing the app after such a big
change.
 
C

Cor Ligthert [MVP]

Ray,

I am not known with tablet PC's however probably it it is related to that,
than try it in the newsgroup

microsoft.public.dotnet.general

I have seen some answers on that in that newsgroup and write than in your
subject "tablet PC"

Cor
 
P

Paul Clement

On 20 Sep 2005 00:43:48 -0700, (e-mail address removed) wrote:

¤ Hello,
¤
¤ First of all, sorry because of my poor english.
¤
¤ I am having a weird problem that I don´t know how to solve. I am not
¤ sure even if it is a problem within the OS or the .NET Framework. The
¤ platform is a Tablet PC device running XP. AFAIK it has installed .NET
¤ 1.1 SP 1.
¤
¤ Depending on what device (Desktop PC or Tablet PC) a certain table (DBF
¤ and MDX file) resides it shows DBNulls on certain columns (it seems
¤ that all the Double fields are affected). I'm not if is a .NET issue,
¤ because if I try to open the table using MS Access it behaves the same
¤ way. If the file is looked in the Tablet PC it shows DBNull values
¤ instead of the original table data. The table has values in that
¤ fields, but it seems to have DBNulls (unless you copy the table to
¤ other file).
¤
¤ If, in the Tablet PC, you execute an SQL update statement against the
¤ table assigning the desired values to the table, the updated rows are
¤ shown correctly (but all other fields remain as DBNull values).
¤
¤ Any help will be appreciated.

If you're seeing the same issue with Microsoft Access then the issue is probably related to the
dBase ISAM driver and not .NET.

It could be the version of MDAC or Jet database engine components you are using. I can't say I've
seen the problem before. Are any of the regional settings different on the Tablet PC?


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top