Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to insert the data to the database
    primarykey
    data
    text
    <p>I want insert the data into the database.</p> <pre><code>string pa = "4898"; string equery="Insert into Users(pas)values('"+pa+"')"; </code></pre> <p>while I inserting the data to the database,its says string or binary data would be truncated the statement has been terminated. So I changed <code>nvarchar(50)</code> into <code>nvarchar(max)</code> in the table.</p> <p>And these statement has been executed and saved in the database of unreadable format like <code>傉䝎਍ਚ</code> this. And how can be over come this problem and save the data in the database as "4898".</p> <pre><code>private void save_Click(object sender, EventArgs e) { string password = "4898"; string equery="Insert into Users(name,gender,dateofbirth,age,fathername, address,citiy,state,country,zipcode, mobile,phone,email,jobtitle, dateofjoin,pic,passwords) values('"+nametxt.Text.ToString().Trim()+"', @gender, '"+dateofbirth.Text.ToString().Trim()+"', '"+age.Value.ToString().Trim()+"', '"+fathertxt.Text.ToString().Trim()+"', '"+addresstxt.Text.ToString().Trim()+"', '"+citiytxt.Text.ToString().Trim()+"', '"+statetxt.Text.ToString().Trim()+"', '"+country.Text.ToString().Trim()+"', '"+ziptxt.Text.ToString().Trim()+"', '"+mobiletxt.Text.ToString().Trim()+"', '"+phonetxt.Text.ToString().Trim()+"', '"+emailtxt.Text.ToString().Trim()+"', '"+jobtxt.Text.ToString().Trim()+ "','"+dateofjoin.Text.ToString().Trim()+"', '"+password+"',@pic)"; SqlCommand cmd = new SqlCommand(equery, con); if(male.Checked) cmd.Parameters.AddWithValue("@gender","Male"); else cmd.Parameters.AddWithValue("@gender","Female"); MemoryStream stream = new MemoryStream(); pictureBox1.Image.Save(stream,System.Drawing.Imaging.ImageFormat.Png); byte[] pic = stream.ToArray(); cmd.Parameters.AddWithValue("@pic", pic); try { con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Saved Successfully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } MessageBox.Show("Saved Successfully"); idtxt.Text = ""; nametxt.Text = ""; age.Value = Convert.ToDecimal(null); male.Checked = false; female.Checked = false; dateofbirth.Text = ""; fathertxt.Text = ""; addresstxt.Text = ""; citiytxt.Text = ""; statetxt.Text = ""; country.Text = ""; ziptxt.Text = ""; mobiletxt.Text = ""; phonetxt.Text = ""; emailtxt.Text = ""; dateofjoin.Text = ""; jobtxt.Text = ""; pictureBox1.Image = null; } </code></pre>
    singulars
    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.
 

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