Skip to content

Sql procedure connection to c#

eser birkan

Asked Jul 26, 2010, 3:03 AM EDT3 answers
Share
LinkedInX
i have a table in sql server 2008 with procedures and triggers but when i want to connect from program to table it says that "a cursor with the name procup does not exist. the statement has beenterminated." procup is in my procedure in sql.i'm sending a executenonquerty. how can i correct that? i'm waiting answer my friends.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • DMR Santosh
    0
    you have to select the database in which you are working once check the dropdown list in sql server 2008 from where you can select the database (or)
    Before giving your command. Just type this

    USE <Your DBname>
    Go

    Then type your query..
    now it will not show any errors.

    Regards,
    D.M.R.Santosh
    0
  • 0
    ---------------------code-----------------------
    namespace Barc
    {
    public partial class DeluxeKasa : Form
    {
    public DeluxeKasa()
    {
    InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
    string connectionString1 = "Server=SARMA-NOTEBOOK\\SQLEXPRESS;Database=Ramses; Trusted_Connection=Yes;";
    SqlConnection mySqlConnection1 = new SqlConnection(connectionString1);
    if (comboBox1.Text == "USD")
    {
    string girenString1 =
    "INSERT into Ramsesdeluxekasa (tarih,girenusd,açiklama,paracinsi,cikanusd) values ('" + dateTimePicker1.Value.Year.ToString() + "-" + dateTimePicker1.Value.Month.ToString() + "-" + dateTimePicker1.Value.Day.ToString() + " " + dateTimePicker1.Value.Hour.ToString() + ":" + dateTimePicker1.Value.Minute.ToString() + ":" + dateTimePicker1.Value.Second.ToString() + ".000','" + maskedTextBox1.Text + "','" + textBox1.Text + "','" + comboBox1.Text + "','0')";
    string cikanString1 =
    "INSERT into Ramsesdeluxekasa (tarih,cikanusd,açiklama,paracinsi,girenusd) values ('" + dateTimePicker1.Value.Year.ToString() + "-" + dateTimePicker1.Value.Month.ToString() + "-" + dateTimePicker1.Value.Day.ToString() + " " + dateTimePicker1.Value.Hour.ToString() + ":" + dateTimePicker1.Value.Minute.ToString() + ":" + dateTimePicker1.Value.Second.ToString() + ".000','" + maskedTextBox1.Text + "','" + textBox1.Text + "','" + comboBox1.Text + "','0')";
    if (radioButton1.Checked)
    {
    SqlCommand mySqlCommand1 = new SqlCommand(girenString1, mySqlConnection1);
    mySqlCommand1.CommandType = CommandType.StoredProcedure;

    mySqlConnection1.Open();
    mySqlCommand1.ExecuteNonQuery();
    mySqlConnection1.Close();
    }
    else if (radioButton2.Checked)
    {
    SqlCommand mySqlCommand1 = new SqlCommand(cikanString1, mySqlConnection1);

    mySqlConnection1.Open();
    mySqlCommand1.ExecuteNonQuery();
    mySqlConnection1.Close();
    }
    MessageBox.Show("Kaydedildi");
    -----------------------code---------------------------
    as you see i'm chosing database.as i said before about procedure there is a problem bcs without procedure it was working.
    0
  • 0
    if you are using sql for your SQL, then change mySqlCommand1.CommandType = CommandType.StoredProcedure; to CommandType.Text
    0