Hi
I need to work on ado.net.
How to pass a data table in sp using ado.net
Thanks
Hi
I need to work on ado.net.
How to pass a data table in sp using ado.net
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Jan 26, 2024, 6:36 PM
You can learn the complete ADO.NET here
https://www.sharpencode.com/article/ADONET/stored-procedure-in-ado-net
Mayooran NavamanyPosted Jan 26, 2024, 6:08 AM
I can explain my code
Database name: SIS,
Table name: student_Info
table has (name, age, address, phone)
you can follow these steps. I'll provide you with a simple example assuming you have a stored procedure named
InsertStudent:Create a DataTable: Create a DataTable with columns corresponding to your
student_Infotable (name, age, address, phone).Create a SqlCommand with CommandType as StoredProcedure: Create a SqlCommand object with the CommandType set to StoredProcedure and the name of your stored procedure.
Ensure that the stored procedure
InsertStudentexists and accepts a parameter of typeDataTable(e.g.,@StudentData).Modify your Stored Procedure: Your stored procedure should be able to handle the DataTable parameter. For example:
Ensure that
dbo.YourTableTypeis a table type that matches the structure of your DataTable (name, age, address, phone).