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.
Carl EvansPosted Jul 29, 2010, 3:00 PM
eser birkanPosted Jul 26, 2010, 9:22 AM
---------------------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.
DMR SantoshPosted Jul 26, 2010, 8:08 AM
Before giving your command. Just type this
USE
Go
Then type your query..
now it will not show any errors.
Regards,
D.M.R.Santosh