asked on
ASKER
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'Declare local variables and objects
Dim objCommand As SqlCommand = New SqlCommand()
'Set the Command object properties
Dim objConnection As New SqlConnection _
("server=Server1;database=brc;integrated Security=true")
Dim IDParm As New SqlParameter("@IDenty", SqlDbType.Int)
IDParm.Direction = ParameterDirection.Output
'Set the SqlCommand object properties
'Open the connection and execute the command
objCommand.Connection = objConnection
objConnection.Open()
objCommand.CommandText = "usp_InsertBRCDetails"
objCommand.CommandType = CommandType.StoredProcedure
'Add the parameters for the placeholders in the SQL CommandText Property
'Parameter for the Title Column
objCommand.Parameters.AddWithValue("@Title", txtTitle.Text)
'Parameter for the Description Column
objCommand.Parameters.AddWithValue("@Description", txtDesc.Text)
'Parameter for the Section Column
objCommand.Parameters.AddWithValue("@Section", txtSection.Text)
'Parameter for the CompiledBy Column
objCommand.Parameters.AddWithValue("@CompiledBy", txtCompiledBy.Text)
'Parameter for the Link column
objCommand.Parameters.AddWithValue("@Link", txtLink.Text)
'Parameter for the Version column
objCommand.Parameters.AddWithValue("@Version", txtVersion.Text)
'Parameter for the Date Column
objCommand.Parameters.AddWithValue("@Date", DTP1.Text)
objCommand.Parameters.Add(IDParm)
'Execute the SqlCommand object to insert the new data
Try
objCommand.ExecuteNonQuery()
Catch SqlExceptionErr As SqlException
MessageBox.Show(SqlExceptionErr.Message)
End Try
Dim NextID As Integer = Convert.ToInt32(IDParm.Value)
MessageBox.Show(NextID, "The Document ID Is")
'Close connection
objConnection.Close()
'Display a message that the record was added
ToolStripStatusLabel1.Text = "Record Added"
'Clear all fields
txtTitle.Text = String.Empty
txtDesc.Text = String.Empty
txtSection.Text = String.Empty
txtCompiledBy.Text = String.Empty
txtLink.Text = String.Empty
DTP1.Text = String.Empty
End Sub
Hi,ASKER
ASKER
Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.
TRUSTED BY