i can not add arabic text to table. text save as question mark ( ????????)
i have a problem to save arabic data in my tabel.
after run below code, i see question mark in datafield
for example i was insert into test2 this values ('الاهلي','شباب') and when i see content of field after insert, i see : '?????','????'
if i use mysql administrator tools(for windows) and insert into table, anything is correct but when i insert with below code, i see question mark in content of field.
what is problem? please guaid me.
my table name is test2. have 3 fields: f1 (autoincrement , integer) , f2(varchar(45),utf8) , f3(varchar(45),utf8)
this is my asp.net code:
------------------------------------------------------------------------------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;uid=test;pwd=test1;"
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
s1 = "(N'" + TextBox1.Text.ToString + "',N'سلامگچ')"
Dim cmd As OdbcCommand = New OdbcCommand("INSERT INTO test2 (f2,f3) VALUES " + s1, con)
Response.Write(cmd.CommandText)
con.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
con.Close()
dgrAllNames.DataBind()
GridView1.DataBind()
end sub
------------------------------------------------------------------------------
and this is my page:
==============================================================================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="2-new.aspx.vb" Inherits="_2_new" CodePage="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server" >
<title>test</title>
<meta name="keywords" content="aaa,ششي ب " />
<meta name="vs_targetSchema" content="
http://schemas.microsoft.com/intellisense/ie5" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="fa" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<p align="center">All records in the 'Names' table:</p>
<asp:DataGrid ID="dgrAllNames" HorizontalAlign="Center" CellPadding="3" Runat="server" Font-Names="tahoma"
DataSourceID="SqlDataSource1" />
<asp:TextBox ID="TextBox1" runat="server" Font-Names="Tahoma">گفتم چگونه </asp:TextBox>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="character set=utf8;server=localhost;user id=test;password=test1;database=test"
ProviderName="MySql.Data.MySqlClient" SelectCommand="select * from test2">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
Visible="true">
</asp:GridView>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
CausesValidation="False" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button2"
CausesValidation="False" />
<p style="font-family: tahoma">
لببيييي ي بل بل بلز بلز ازرژژژژ</p>
<p>
</p> </div>
</form>
</body>
</html>
==============================================================================