第一期表在同一時間從一個表中的數據插入到另一個我想使用SQL Server存儲過程
BookID | BookName | DateIssue | ReturnDate | PersonID
| | | |
1 | Sqlserver| 4/4/2015 | 5/5/2015 | 22
我想從tblIssue值插入到返回表,但是,不能.. 。 第二回表
BookID | BookName | DateIssue | ReturnDate | PersonID
| | | |
1 | Sqlserver| 4/4/2015 | 5/5/2015 | 22
查詢在SQL Server中運行。我想,我在SQL Server查詢錯誤
Stored proc query:
'CREATE PROCEDURE inserttwo
(
@BookID int,
@BookName nvarchar(50),
@DateIssue datetime,
@ReturnDate datetime,
@PersonID int
)
as
insert into tblReturn(BookID,BookName,DateIssue,ReturnDate,PersonID)
values(@BookID,@BookName,@DateIssue,@ReturnDate,@PersonID)
select * from tblIssue
誤差在c#:
Procedure or function 'inserttwo' expects parameter '@BookID',
which was not supplied.
這裏它指向錯誤:sda.Fill(DT);
C# code:
public void storedproc()
{
string w = ConfigurationManager.ConnectionStrings["LMS"].ConnectionString;
SqlConnection conn = new SqlConnection(w);
DataTable dt = new DataTable();
SqlCommand cmd = new SqlCommand("inserttwo", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter sda = new SqlDataAdapter(cmd);
conn.Open();
sda.Fill(dt);
metroGrid1.DataSource = dt;
conn.Close(); }
它在給出的BookId在當前上下文中不存在錯誤後給出一個錯誤。 – Warda
@Warda是的,你必須設置你想插入的書的價值 – fubo
好吧告訴我...是否正確查詢插入兩個表一次? – Warda