Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generics: T x = 5 fails Pin
Christian Graus17-Aug-06 1:40
protectorChristian Graus17-Aug-06 1:40 
GeneralRe: Generics: T x = 5 fails Pin
Nader Elshehabi17-Aug-06 2:07
Nader Elshehabi17-Aug-06 2:07 
GeneralRe: Generics: T x = 5 fails Pin
Christian Graus17-Aug-06 2:15
protectorChristian Graus17-Aug-06 2:15 
GeneralRe: Generics: T x = 5 fails [modified] Pin
Nader Elshehabi17-Aug-06 2:39
Nader Elshehabi17-Aug-06 2:39 
GeneralRe: Generics: T x = 5 fails Pin
Christian Graus17-Aug-06 2:47
protectorChristian Graus17-Aug-06 2:47 
GeneralRe: Generics: T x = 5 fails Pin
eggsovereasy17-Aug-06 4:02
eggsovereasy17-Aug-06 4:02 
QuestionEnterprise deployment console Pin
abhinish16-Aug-06 22:39
abhinish16-Aug-06 22:39 
QuestionClasses [modified] Pin
Mamphekgo16-Aug-06 22:03
Mamphekgo16-Aug-06 22:03 
Hi.
I have created a class that read data from the database and i want to display this data on labels.

here is my class

public void SeachProduct(string PBarcode,string PName,string PPrice)
{
Barcode = PBarcode;
ProductName = PName;
Price = PPrice;


SqlConnection conn1 = new SqlConnection();
conn1.ConnectionString = "integrated security=SSPI;initial catalog=Phusa;server = za211149;persist security info=False";
conn1.Open();
try
{
SqlCommand cmdSearch1 = new SqlCommand();
cmdSearch1.Connection = conn1;
cmdSearch1.CommandText = "SELECT ProductName,Price FROM Products WHERE Barcode=@Barcode";

SqlParameter Bar = new SqlParameter();
Bar.ParameterName = "@Barcode";
Bar.Direction = System.Data.ParameterDirection.Input;
Bar.Value = Barcode;
cmdSearch1.Parameters.Add(Bar);

SqlParameter Nam1 = new SqlParameter();
Nam1.ParameterName="@ProductName";
Nam1.Direction = System.Data.ParameterDirection.Output;
Nam1.Value =ProductName;
cmdSearch1.Parameters.Add(Nam1);

SqlParameter Pri= new SqlParameter();
Pri.ParameterName = "@Price";
Pri.Direction = System.Data.ParameterDirection.Output;
Pri.Value = Price;
cmdSearch1.Parameters.Add(Pri);


SqlDataReader dr1 =cmdSearch1.ExecuteReader();
if(dr1.Read()==true)
{

//MessageBox.Show("Product found");
ProductName= dr1["ProductName"].ToString();
Price = dr1["Price"].ToString();


}
else
{
MessageBox.Show("Product not found");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn1.Close();
}

and here i am try to call so that it can display data on the labels my class on form

SearchCustomers search = new SearchCustomers();
string Barcode;
string ProductName="";
string Price = "";

Barcode = txtBarcode.Text;

search.SeachProduct(Barcode,ProductName,Price);
lblProductName.Text = ProductName;
lblPrice.Text =Price;
}



-- modified at 4:03 Thursday 17th August, 2006
AnswerRe: Classes Pin
Guffa16-Aug-06 22:13
Guffa16-Aug-06 22:13 
QuestionHow create uninstal project? Pin
ersinsivaz16-Aug-06 21:49
ersinsivaz16-Aug-06 21:49 
AnswerRe: How create uninstal project? Pin
Nader Elshehabi17-Aug-06 1:49
Nader Elshehabi17-Aug-06 1:49 
QuestionServer Image Path Pin
nachisaravanan16-Aug-06 21:45
nachisaravanan16-Aug-06 21:45 
AnswerRe: Server Image Path Pin
Christian Graus16-Aug-06 21:47
protectorChristian Graus16-Aug-06 21:47 
GeneralRe: Server Image Path Pin
nachisaravanan16-Aug-06 22:26
nachisaravanan16-Aug-06 22:26 
GeneralRe: Server Image Path Pin
Christian Graus16-Aug-06 22:35
protectorChristian Graus16-Aug-06 22:35 
AnswerRe: Server Image Path Pin
Guffa16-Aug-06 22:19
Guffa16-Aug-06 22:19 
GeneralRe: Server Image Path Pin
nachisaravanan16-Aug-06 22:28
nachisaravanan16-Aug-06 22:28 
QuestionSending pdf file directly to printer Pin
Support12316-Aug-06 21:34
Support12316-Aug-06 21:34 
QuestionUsing Flat Files with NHibernate Pin
rakesh.motghare16-Aug-06 21:26
rakesh.motghare16-Aug-06 21:26 
Questionhow to use ListView Control in C#.net? Pin
yousafzai16-Aug-06 21:05
yousafzai16-Aug-06 21:05 
AnswerRe: how to use ListView Control in C#.net? Pin
coolestCoder16-Aug-06 21:19
coolestCoder16-Aug-06 21:19 
GeneralRe: how to use ListView Control in C#.net? Pin
chandler8316-Aug-06 21:26
chandler8316-Aug-06 21:26 
GeneralRe: how to use ListView Control in C#.net? Pin
yousafzai16-Aug-06 21:45
yousafzai16-Aug-06 21:45 
GeneralRe: how to use ListView Control in C#.net? Pin
chandler8316-Aug-06 22:48
chandler8316-Aug-06 22:48 
QuestionActiveX control in C#, client in C++, subscribe to event Pin
__alex16-Aug-06 20:37
__alex16-Aug-06 20:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.