Call a stored procedure from ado.net and pass parameter to it ?
Answer Posted / naresh
Private Sub btnSave_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSave.Click
connection = New SqlConnection("Integrated
Security=sspi; database=naresh; data source=TECH-FATIMA1")
Try
connection.Open()
command = New SqlCommand("spEmployee_Insert")
command.Connection = connection
command.CommandType =
CommandType.StoredProcedure
command.Parameters.AddWithValue("@Name",
txtName.Text)
command.Parameters.AddWithValue("@Dept",
txtDept.Text)
command.Parameters.AddWithValue("@Address",
txtAddress.Text)
Dim result As Integer
result = command.ExecuteNonQuery()
If result > 0 Then
MessageBox.Show("Sucessfully Stored In
Database")
End If
Catch ex As Exception
MessageBox.Show("DataBase Connection Problem")
Finally
connection.Close()
End Try
End Sub
Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
What are the advantages and disadvantages of using datalist?
oledbdataadpter with ms access in c#.net giving exception System.Data.OleDb.OleDbException while writing adapter.update(dataset,"tabname"); how to update the database from dataset?
What is csdl entity framework?
What is the use of connection object in ado.net?
Explain how to create dynamic gridview?
How do you update a dataset in ado.net?
How to identify the controls which can be used for binding data?
Which one of the objects is a high-level abstraction of the connection and command objects in ado.net?
What is data reader in ado.net?
What is serialization and de-serialization in .net?
What is different between sqlcommand object and command behavior object?
What is the difference between Datareader and Dataset?
If a table contains 20000 records. In a page at each time 100 records to be displayed.
Is entity framework better than ado.net?
Is ado.net an orm?