Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove last two characters of value stored in string veriable
    primarykey
    data
    text
    <p>I am developing an app in VS2010 c# to fetch a single row data from SQLServer and insert it to MySQL.</p> <p>I have fetched data and stored in particular string variable. Fetching code is as below.</p> <pre><code>SqlCommand cmd = new SqlCommand("SELECT TOP (1) s_name, s_city, s_address, s_added_date, s_added_by FROM tblAQI ORDER BY s_added_date DESC", SSCon); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { s_name = (dr["s_name"].ToString()); s_city = (dr["s_city"].ToString()); s_address = (dr["s_address"].ToString()); s_added_date = (dr["s_added_date"].ToString()); s_added_by = (dr["s_added_by"].ToString()); } </code></pre> <p>All stores value in string format. Problem is in s_added_date this variable contains datetime value i.e. like 11/15/2013 12:01:00 AM unable to insert into MySQL I think because of AM.</p> <p>My Insertion code is as below.</p> <pre><code> mcmd.CommandText = "INSERT INTO tblaqi(s_name,s_city,s_address,s_added_date,s_added_by) VALUES(@s_name,@s_city,@s_address,s_added_date,s_added_by)"; mcmd.Parameters.AddWithValue("@s_name", s_name); mcmd.Parameters.AddWithValue("@s_city", s_city); mcmd.Parameters.AddWithValue("@s_address", s_address); mcmd.Parameters.AddWithValue("@s_added_by", s_added_by); mcmd.Parameters.AddWithValue("@s_added_date", s_added_date); int count = mcmd.ExecuteNonQuery(); if (count != 0) { MessageBox.Show("Success..!!"); } else MessageBox.Show("Need to work"); </code></pre> <p>my question is what will be the problem in this.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload