Sql procedure connection to c#
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 Santosh14 pointsPosted Jul 26, 2010, 4:08 AM EDT
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
eser birkan2 pointsPosted Jul 26, 2010, 5:22 AM EDT
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.
Carl Evans6 pointsPosted Jul 29, 2010, 11:00 AM EDT