Note that there are some explanatory texts on larger screens.

plurals
  1. POExecuteNonQuery Overflow Error ?
    primarykey
    data
    text
    <p>I've been trying to figure what is wrong with the code.</p> <p>What I'm trying to do is that there are two Radiobuttons for gender, Male &amp; Female...</p> <p>I want that when Male radiobutton is clicked, the text MALE is saved into the database in the gender field which if of type text, but instead I'm getting an overflow error...</p> <p>Before adding the radiobuttons and the [GENDER] field, everything was working fine...</p> <p>So any help with it?</p> <pre><code> using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace OfflineRF { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string gender; private void button1_Click(object sender, EventArgs e) { string ORF1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\\OfflineRF.mdb"; OleDbConnection conn = new OleDbConnection(ORF1); conn.Open(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = conn; cmd.CommandText = "INSERT INTO OFFRF([Fname], [Lname], [NIC], [Gender], [HomeTel], [Cellphone], [Passengers], [From], [To])VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + textBox7.Text + textBox8.Text +"','"+gender+"','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + comboBox1.Text + "','" + comboBox2.Text + "')"; cmd.ExecuteNonQuery(); conn.Close(); System.Windows.Forms.MessageBox.Show("Form Saved Successfully !", "Caption", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox1.Text == "Karachi") { comboBox2.Items.Clear(); comboBox2.Items.Add("Sukkur"); comboBox2.Items.Add("Hyderabad"); } else if (comboBox1.Text == "Sukkur") { comboBox2.Items.Clear(); comboBox2.Items.Add("Karachi"); comboBox2.Items.Add("Hyderabad"); } else { comboBox2.Items.Clear(); comboBox2.Items.Add("Karachi"); comboBox2.Items.Add("Sukkur"); } } private void Male_CheckedChanged(object sender, EventArgs e) { if (Male.Checked) gender = "Male"; else gender = "Female"; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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