Here is the way i create a DBF file = ANSI file :
var path = @"Z:\";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=dBASE IV;User ID=Admin;Password=;";
OleDbConnection con = new OleDbConnection(constr);
con.Open();
string CreateTableK =
"CREATE TABLE TEST (ID char(50),NAME char(50),FAMILY char(50))";
OleDbCommand cmdCreateTable = new OleDbCommand(CreateTableK, con);
cmdCreateTable.ExecuteNonQuery();
string MyInsert =
"insert into TEST ( ID, NAME, FAMILY ) values ( ?, ?, ? )";
OleDbCommand cmd3 = new OleDbCommand(MyInsert, con);
cmd3.Parameters.AddWithValue("parmSlot1", "22");
cmd3.Parameters.AddWithValue("parmSlot2", "Oliver");
cmd3.Parameters.AddWithValue("parmSlot3", "¢ُںُ");
cmd3.ExecuteNonQuery();
MessageBox.Show("done");
i removed all using... for clarify what am i saying.
Now open TEST.DBF
file in Drive Z:\
and see how parmSlot3 has changed.
I want to have "¢ُںُ"
string with no change in DBF file.
How can i define encoding of DBF file or How can i do this job?
Also in the other hand i want to read that string from DBF file and work with that string.
Here is the codes :
var path = @"Z:\";
var fileName = "TEST.DBF";
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=dBASE IV;";
using (OleDbConnection con = new OleDbConnection(constr))
{
var sql = "select * from " + fileName;
OleDbCommand cmd = new OleDbCommand(sql, con);
con.Open();
OleDbDataReader reader = cmd.ExecuteReader();
string value = "";
if (!reader.HasRows)
{
//BLO BLO BLO
}
else
{
while (reader.Read())
{
value = reader.GetString(2);
break;
}
}
}
but after these codes value is different from "¢ُںُ"
string.
How can i get "¢ُںُ"
string instead of "تُاُ"
?