ghassan_aljabiri
Member
- Joined
- Mar 25, 2009
- Messages
- 23
- Programming Experience
- Beginner
hello
I added the following stored procedure to the data base , it adds a record to a table
---------------------------------------------
----------------------------------------------
it works fine if I excute it from the SQL Server
---------------------------------------------
then I wrote this code to call it from a vb.net application
------------------------------------------------------
-------------------------------------------------
the code excutes fine , and the message of "done successfully" is displayed
But no records were added to the Data Base , is it a bug or what?
I added the following stored procedure to the data base , it adds a record to a table
---------------------------------------------
VB.NET:
ALTER PROCEDURE dbo.AddNewLabStoredProcedure
(
@LabName as nvarchar(MAX),
@LabSite as nvarchar(MAx),
@LabSupervisor as nvarchar(MAX),
@LabisActive as bit
)
AS
INSERT INTO Labs (LabName,LabSite,LabSupervisor,LabisActive)
values (@LabName,@LabSite,@LabSupervisor,@LabisActive)
RETURN
it works fine if I excute it from the SQL Server
---------------------------------------------
then I wrote this code to call it from a vb.net application
------------------------------------------------------
VB.NET:
Private Sub AddLab()
Dim nl As New AddLabDialog
Dim result As DialogResult
result = nl.ShowDialog
If result = Windows.Forms.DialogResult.OK Then
Dim constr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=true"
Dim con As New System.Data.SqlClient.SqlConnection(constr)
con.Open()
Dim com As New System.Data.SqlClient.SqlCommand
com.Connection = con
com.CommandType = CommandType.StoredProcedure
com.CommandText = "AddNewLabStoredProcedure"
com.Parameters.AddWithValue("LabName", nl.LabName)
com.Parameters.AddWithValue("LabSite", nl.LabSite)
com.Parameters.AddWithValue("LabSupervisor", nl.LabSupervisor)
com.Parameters.AddWithValue("LabisActive", nl.isActive)
Dim AddedRows As Integer
AddedRows = com.ExecuteNonQuery()
If AddedRows = 0 Then
ToolStripStatusLabel1.Text = "Error Occured"
Else
ToolStripStatusLabel1.Text = "done successfully"
End If
con = Nothing
com = Nothing
End If
nl = Nothing
End Sub
the code excutes fine , and the message of "done successfully" is displayed
But no records were added to the Data Base , is it a bug or what?
Last edited: