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


Please Help Members By Posting Answers For Below Questions

What are the advantages and disadvantages of using datalist?

519


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?

1920


What is csdl entity framework?

545


What is the use of connection object in ado.net?

557


Explain how to create dynamic gridview?

512






How do you update a dataset in ado.net?

537


How to identify the controls which can be used for binding data?

539


Which one of the objects is a high-level abstraction of the connection and command objects in ado.net?

624


What is data reader in ado.net?

492


What is serialization and de-serialization in .net?

486


What is different between sqlcommand object and command behavior object?

531


What is the difference between Datareader and Dataset?

534


If a table contains 20000 records. In a page at each time 100 records to be displayed.

509


Is entity framework better than ado.net?

473


Is ado.net an orm?

506