SQL Server:插入关系表

时间:2015-02-01 10:19:11

标签: c# sql sql-server insert relational-database

我想在名为R_Kitap_Al的关系表中插入一个元组。但是我得到了这个错误:

  

System.Data.SqlClient.SqlException(0x80131904):无效的对象名称' Kitap_Al'。

但我没有Kitap_Al表。我想这是我原来的名字。因为我得到了这个错误,但我该怎么办呢。

private void button1_Click(object sender, EventArgs e)
{
    SqlConnection conn = new SqlConnection(@"Data Source=HP\SQLEXPRESS;Initial Catalog=Kütüphane;Integrated Security=True");

    conn.Open();
    SqlCommand cmd = new SqlCommand("INSERT INTO R_Kitap_Al (SSN, Book_No, BaslamaTarihi, BitisTarihi) VALUES (@SSN, @Book_No, @BaslamaTarihi, @BitisTarihi)", conn);

    DateTime dt = new DateTime();
    cmd.Parameters.AddWithValue("@SSN", sSNTextBox.Text);
    cmd.Parameters.AddWithValue("@Book_No", book_NoTextBox.Text);
    //cmd.Parameters.AddWithValue("@BookName",bookNameTextBox.Text);
    cmd.Parameters.AddWithValue("@BaslamaTarihi", baslamaTarihiDateTimePicker.Value);

    dt = Convert.ToDateTime(baslamaTarihiDateTimePicker.Value);
    dt = dt.AddDays(0);
    bitisTarihiDateTimePicker.Value = dt.AddDays(15);
    cmd.Parameters.AddWithValue("@BitisTarihi", bitisTarihiDateTimePicker.Value);

    cmd.ExecuteNonQuery();

    this.Hide();

    R_Kitap_Al kit = new R_Kitap_Al();
    kit.ShowDialog();

    this.Close();
}

1 个答案:

答案 0 :(得分:1)

R_Kitap_Al是否有与之关联的触发器。触发器是否有误并访问Kittap_AI