cyberjay82
Programmer
Here is my stored procedure in my sql database:
CREATE PROCEDURE [dbo].[Search] (@param0 nvarchar, @param1 nvarchar,@param2 nvarchar,@param3 nvarchar,@param4 nvarchar,@param5 nvarchar,@param6 nvarchar,@param7 nvarchar)
AS
SET NOCOUNT ON;
SELECT Number, PartNumber, Description, Cost, Quote, Quanity, PaymentType, Employee, Vendor, VRepresentative, ShippedFrom, Customer, Notes, QuanityReceived, DateReceived, ReceivedBy, InvoiceNumber, Pending, DateOrdered FROM [Order/Received] WHERE Description LIKE @param0 AND PartNumber LIKE @param1 AND ShippedFrom LIKE @param2 AND Customer LIKE @param3 AND DateOrdered LIKE @param4 AND Employee LIKE @param5 AND Vendor LIKE @param6 AND PaymentType LIKE @param7 ORDER BY Description;
GO
Here is my code in my C# form(vs.net):
sqlDataAdapter1.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
sqlDataAdapter1.SelectCommand.CommandText = "Search";
sqlDataAdapter1.SelectCommand.Parameters.Clear();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param0", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param0"].Value = descS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param1", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param1"].Value = partS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param2", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param2"].Value = shipS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param3", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param3"].Value = custS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param4", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param4"].Value = dateS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param5", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param5"].Value = empS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param6", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param6"].Value = venS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param7", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param7"].Value = payS.ToString();
sqlDataAdapter1.Fill(ord);
DataTable dtO = ord.Tables[0];
foreach(DataRow drO in dtO.Rows)
{
etc...
Am I doing stomething wrong because I keep getting no records in my datarows. This is the first time I am using stored procedures with C# and I don't know if I am doing this right. Any advice will be helpful. Thanks.
CREATE PROCEDURE [dbo].[Search] (@param0 nvarchar, @param1 nvarchar,@param2 nvarchar,@param3 nvarchar,@param4 nvarchar,@param5 nvarchar,@param6 nvarchar,@param7 nvarchar)
AS
SET NOCOUNT ON;
SELECT Number, PartNumber, Description, Cost, Quote, Quanity, PaymentType, Employee, Vendor, VRepresentative, ShippedFrom, Customer, Notes, QuanityReceived, DateReceived, ReceivedBy, InvoiceNumber, Pending, DateOrdered FROM [Order/Received] WHERE Description LIKE @param0 AND PartNumber LIKE @param1 AND ShippedFrom LIKE @param2 AND Customer LIKE @param3 AND DateOrdered LIKE @param4 AND Employee LIKE @param5 AND Vendor LIKE @param6 AND PaymentType LIKE @param7 ORDER BY Description;
GO
Here is my code in my C# form(vs.net):
sqlDataAdapter1.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
sqlDataAdapter1.SelectCommand.CommandText = "Search";
sqlDataAdapter1.SelectCommand.Parameters.Clear();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param0", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param0"].Value = descS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param1", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param1"].Value = partS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param2", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param2"].Value = shipS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param3", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param3"].Value = custS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param4", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param4"].Value = dateS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param5", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param5"].Value = empS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param6", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param6"].Value = venS.ToString();
sqlDataAdapter1.SelectCommand.Parameters.Add("@param7", System.Data.SqlDbType.NVarChar);
sqlDataAdapter1.SelectCommand.Parameters["@param7"].Value = payS.ToString();
sqlDataAdapter1.Fill(ord);
DataTable dtO = ord.Tables[0];
foreach(DataRow drO in dtO.Rows)
{
etc...
Am I doing stomething wrong because I keep getting no records in my datarows. This is the first time I am using stored procedures with C# and I don't know if I am doing this right. Any advice will be helpful. Thanks.