forum

Home / DeveloperSection / Forums / ADO.NET Insert Mysql, All data is null

ADO.NET Insert Mysql, All data is null

Kate Smith260319-Jun-2013
Hi Developers, 

I have created a winform application, and use ado.net to access mysql database. But I encountered a strange problem.

my data table create script:

create table using_user {
 `id` int(11) NOT NULL auto_increment, 
 'dip_addr' default NULL,
 'scard_type' default NULL,
 ....
}

my c# code:

MySqlConnection conn = new MySqlConnection();
conn.ConnectionString = "Server=localhost; Port=9999; Uid=root; Pwd=ecsc; Database=zhz-netbar-jk;"

conn.Open();

MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "insert into using_user (dip_addr, scard_type,...)values(@dip_addr, @scard_type,...)";

cmd.Parameters.Add(new MySqlParameter("@dip_addr", "5000230001"));
cmd.Parameters.Add(new MySqlParameter("@scard_type", "1"));
...

cmd.ExecuteNonQuery();

conn.Close();

After do this, the primary key 'id' was generated, but other fields are NULL. How can I resolve this problem?

Updated on 19-Jun-2013

Can you answer this question?


Answer

1 Answers

Liked By