Sir/Madam,
I have doubt with calling stored procedure from front end.
Create Procedure ProcedureName
(@Input1 DataType
@Input2 DataType)
AS
Begin
SELECT * FROM Table1
Insert INTO Table1 VALUES(@Input1, @Input2)
End
In the above procedure how to get value for select command.
With Regards,
Gomathi.P
Loading


Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 21, 2010, 2:36 AM EDT
Create Procedure ProcedureName
(@Input1 DataType
@Input2 DataType)
AS
Begin
SELECT * FROM Table1
Insert INTO Table1 VALUES(@Input1, @Input2)
SELECT * FROM Table1
End
R J192 reputationPosted Sep 21, 2010, 2:45 AM EDT
to call the stored procedure from front end... follow this
1. Create a new C# Windows Application project.
2. From the Toolbox, drag and drop a DataGrid onto the Form. Resize it as necessary.
3. Double-click on the Form to generate the Form_Load event handler. Before entering any code, add "using System.Data.SqlClient" at the top of the file.
Enter the following code:
private void Form1_Load(object sender, System.EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=localhost;Database=databasename;Integrated Security=SSPI"); SqlCommand command = new SqlCommand("Procedurename", conn); SqlDataAdapter adapter = new SqlDataAdapter(command); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Input1", SqlDbType.Datatype).Value = input1; command.Parameters.Add("@Input2", SqlDbType.datatype).Value = input2; int rows = command.ExecuteNonQuery();DataSet ds = new DataSet();
adapter.Fill(ds, "tablename");
this.dataGrid1.DataSource = ds;
this.dataGrid1.DataMember = "tablename";
}
Gomathi PalaniswamyRank #714 · 3.3K reputationPosted Sep 21, 2010, 2:52 AM EDT
Is it possible to exec select command alone with this procedure?
With Regards,
Gomathi.P
R J192 reputationPosted Sep 21, 2010, 3:15 AM EDT
(@Input1 DataType
@Input2 DataType)
AS
Begin
SELECT * FROM Table1
Insert INTO Table1 VALUES(@Input1, @Input2)
SELECT * FROM Table1
End
-------
now execute the stored procedure like this