title: Insert failed due to Null ERROR [HY000] [MySQL][ODBC 3.51
body: <p>My questions :</p>
  
  <p>What am doing wrong with this query, it confusing me a lot, can anyone suggest me the solution: am using the query as:</p>
  
  <pre><code>Dim constr As String = "Dsn=check;database=db;description=check;option=0;port=0;server=localhost;uid=root"
  Dim con As New OdbcConnection(constr)
  Dim mysql As String = "insert into parameter(col3,col1,col2) values(@val3,@val1,@val2)"
  Dim cmd As New OdbcCommand
  With cmd
      .CommandType = CommandType.Text
      .CommandText = mysql
      .Connection = con
      .Parameters.Add(New OdbcParameter("@val1", "C005"))
      .Parameters.Add(New OdbcParameter("@val2", "C006"))
      .Parameters.Add(New OdbcParameter("@val3", 55))
  End With
  con.Open()
  MsgBox(cmd.ExecuteNonQuery()) '&lt;--- this line giving error as given below
  con.Close() 
  </code></pre>
  
  <blockquote>
    <p>ERROR [HY000] [MySQL][ODBC 3.51
    Driver][mysqld-5.0.37-community-nt-log]Column 'col3' cannot be null</p>
  </blockquote>
  
  <p>but i am adding value to this parameter <code>.Parameters.Add(New OdbcParameter("@val3", 55))</code> then why this error is occuring?</p>
  
  <p>The <code>col3</code> is primary key for my table. so if i put auto increment for the primary key field and then give values to <code>col1</code> and <code>col2</code> then it inserts <code>NULL</code> values to the table.</p>
  
  <p><strong>If i use like the following : will works fine Problem occured while using the parameterised query, this is the first time am using parameterised query</strong></p>
  
  <pre><code>Dim mysql As String = "insert into parameter(col3,col1,col2) values(55,'C005','C006')"
      Dim cmd As New OdbcCommand
      With cmd
          .CommandType = CommandType.Text
          .CommandText = mysql
          .Connection = con
      End With
      con.Open()
      MsgBox(cmd.ExecuteNonQuery())
      con.Close 
  </code></pre>
  
  <p>am using <strong>odbc driver 3.5</strong> and <strong>visual studio 2010</strong></p>
  
  <p><img src="https://i.stack.imgur.com/Eo9TA.jpg" alt="enter image description here"></p>
  
  <p>The structure of the table am using:</p>
  
  <pre><code>CREATE TABLE  `db`.`parameter` (
    `col3` int(11) NOT NULL default '0',
    `col1` text,
    `col2` text,
    PRIMARY KEY  (`col3`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  </code></pre>