我試圖用存儲過程與Linq To SQL插入數據。 我沒有收到任何錯誤消息,我的數據也沒有插入。 代碼是在VB中,因爲我也在這個項目中使用XML。Linq存儲過程插入沒有結果
代碼
Using db As New booksDataContext()
db.testprocedure("kkk")
db.SubmitChanges()
End Using
存儲過程
ALTER PROCEDURE testprocedure
(
@test varchar(50)
)
AS
BEGIN
INSERT INTO test (testcolum)
VALUES (@test)
END
我能本身它會在這個功能時,我調試和它的返回0
<Global.System.Data.Linq.Mapping.FunctionAttribute(Name:="dbo.testprocedure")> _
Public Function testprocedure(<Global.System.Data.Linq.Mapping.ParameterAttribute(DbType:="VarChar(50)")> ByVal test As String) As Integer
Dim result As IExecuteResult = Me.ExecuteMethodCall(Me, CType(MethodInfo.GetCurrentMethod,MethodInfo), test)
Return CType(result.ReturnValue,Integer)
End Function
我已經做了選擇作品perfekt所以它沒有錯datacontext
Sub SelectAllBooks()
Dim db As New booksDataContext()
For Each book In db.SelectBooks("Madde")
Dim title = book.title
Dim author = book.author
Dim genre = book.genre
Dim price = book.price
Dim publish_date = book.publish_date
Dim description = book.description
Dim bookid = book.bookid
Console.WriteLine(title & " " & author & " " & genre & " " & price & " " & publish_date & " " & description & " " & bookid)
Next
Console.ReadLine()
End Sub
謝謝您的幫助
如果你運行SQLProfiler你能看到你的語句執行嗎? – Jodrell