Carlos Guzmán Álvarez wrote:
> Hello:
>> Sometimes, when I use stored procedures, some characters are not stored
>> correctly in the database. '€' (euro) is one of them.
> The sample seems to be using DevExpress assemblies so i can't test it,
> anywy
> Hello:
>> Sometimes, when I use stored procedures, some characters are not stored
>> correctly in the database. '€' (euro) is one of them.
> The sample seems to be using DevExpress assemblies so i can't test it,
> anywy
Sorry, just use the attached Form1.cs
and remove the references to devex
in the project.
in the project.
> you are using Character Set NONE
in the connection string when you
> should be using ISO8859_1
> should be using ISO8859_1
This new Form1.cs uses
the correct character set in the connection
string but the problem still occurs
string but the problem still occurs
In fact, if I execute the sp_Unite_Insert
procedure directly from EMS IB Manager, this works perfectly and the € character
is correct.
TIA, Julien
using System; using System.Data; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using FirebirdSql.Data.Firebird;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private FirebirdSql.Data.Firebird.FbConnection fbConnection1;
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after
InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.fbConnection1 = new
FirebirdSql.Data.Firebird.FbConnection();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// fbConnection1
//
this.fbConnection1.ConnectionString =
"User=SYSDBA;Password=masterkey;Database=D:\\Essais\\Bases Test\\EVEREST
TEST.FDB;Dat" +
"aSource=localhost;Port=3050;Dialect=3;Charset=ISO8859_1;Role=;Connection
lifetim" +
"e=0;Connection timeout=15;Pooling=True;Packet
Size=8192;Server Type=0";
//
// button1
//
this.button1.Location = new System.Drawing.Point(20,
30);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new
System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(457, 356);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
using (FbConnection connection = new
FbConnection(@"User=SYSDBA;Password=masterkey;Database=D:\Essais\Bases
Test\EVEREST
TEST.FDB;DataSource=localhost;Port=3050;Dialect=3;Charset=ISO8859_1;Role=;Connection
lifetime=0;Connection timeout=15;Pooling=True;Packet Size=8192;Server Type=0"))
{
connection.Open();
FbTransaction transaction =
connection.BeginTransaction();
try
{
FbDataAdapter dataAdapter = new
FbDataAdapter();
FbCommand commande = new FbCommand("",
connection, transaction);
dsUnité dataSet = new dsUnité();
dataSet.DataSetName = "dsUnité";
commande.CommandText =
"sp_Unite_Insert";
commande.CommandType =
CommandType.StoredProcedure;
commande.Parameters.Add(new
FbParameter("@Libelle", FbDbType.VarChar, 0, "Libelle"));
commande.Parameters.Add(new
FbParameter("@Symbole", FbDbType.VarChar, 0, "Symbole"));
commande.Parameters.Add(new
FbParameter("@Id", FbDbType.Integer, 0, ParameterDirection.Output, true, 0, 0,
"Id", DataRowVersion.Current, -1));
dataAdapter.InsertCommand = commande;
dataAdapter.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new
System.Data.Common.DataTableMapping("Table", "Unite", new
System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Id", "Id"),
new System.Data.Common.DataColumnMapping("Libelle", "Libelle"),
new System.Data.Common.DataColumnMapping("Symbole", "Symbole")})});
DataRow row =
dataSet.Tables["Unite"].NewRow();
row["Id"] = 0;
row["Libelle"] = "test euro : ";
row["Symbole"] = "ABC";
dataSet.Tables["Unite"].Rows.Add(row);
dataAdapter.Update(dataSet);
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
}
}
}
