Results 1 to 2 of 2

Thread: cmd.ExecuteReader() syntax problem

  1. #1
    Join Date
    Nov 2009
    Posts
    1

    cool cmd.ExecuteReader() syntax problem

    Can anyone help me in the following code I am facing a error.after SqlDataReader reader = cmd.ExecuteReader();in the following code.

    private void button1_Click(object sender, EventArgs e)
    {
    SqlConnection con = new SqlConnection("Data Source=STUDENT-1D40FC5\\SQLEXPRESS; Initial Catalog=SubscriptionMGNT; Integrated Security=SSPI");
    string query = "insert into newsubscription(name,address,post,taluk,district,pin,mobile,tel,state,country,bname,bcode,yrs,issues ,start,end,cheque,bank,ddate,amt)values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "','" + comboBox1.Text + "','" + textBox11.Text + "','" + comboBox3.Text + "','" + textBox12.Text + "','" + comboBox4.Text + "','"+comboBox2.Text+"','"+textBox13.Text+"','"+textBox14.Text+"','"+comboBox5.Text+"','"+textBox15. Text+"')";
    SqlCommand cmd = new SqlCommand(query,con);
    con.Open();
    SqlDataReader reader = cmd.ExecuteReader();

    MessageBox.Show("A New Subscription Has Been Created");
    while (reader.Read())
    {

    }
    reader.Close();


    }

  2. #2
    Join Date
    May 2009
    Posts
    543

    Re: cmd.ExecuteReader() syntax problem

    Looks like an error in the request. Get the whole text of the query and run it in SQL Query Analyser, see what he would give. It would obviously be better to just make it a SQL query ->. This should be modified accordingly. Just search google and SQL JOIN. You have the choice to run queries, stored procedures, via a command object.

Similar Threads

  1. What are the Basic Syntax used in PHP?
    By Steyn in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 12:49 AM
  2. Problem with header() + syntax
    By Leiff in forum Software Development
    Replies: 4
    Last Post: 22-01-2010, 11:07 PM
  3. Replies: 3
    Last Post: 03-09-2009, 05:41 PM
  4. Syntax for SQL query in JSP.
    By elldeegee in forum Software Development
    Replies: 3
    Last Post: 04-06-2009, 10:44 AM
  5. ExecuteReader requires an open and available Connection.
    By AmolP in forum Software Development
    Replies: 1
    Last Post: 03-02-2009, 07:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,002,648.13559 seconds with 17 queries