Dear what the hell you are doing. first tell me what does command contains,
i mean what are the parameters, where you declared that, rather you declare
the object here itself and do the following:
public void fillCombo(string instrutorName)
{
SqlCommand cmd = new Sqlcommand
("StoredProcNAme","connectionString");
SqlParameter par =
cmd.Parameters.Add("@instructor",SqlDBtype.Varchar, 30);
par.Value = instructorName;
SqlDataReader dr;
dr = cmd.ExecuteReader();
while(dr.Read())
{
comboBox1.Items.Add(dr["Course"].ToString());
}
}
call it on form load
let me know the result
Regards,
Khushal
>From: "Jasmine" <jasmine2501 (AT) netzero (DOT) com>
>Reply-To: CSharpNET (AT) yahoogroups (DOT) com
>To: CSharpNET (AT) yahoogroups (DOT) com
>Subject: [C#.NET] Re: whats wrong with this segment of code i'm going to
>get anger
>Date: Tue, 19 Sep 2006 15:28:50 -0000
>
>You need to be more specific than "doesn't work", as there are no
>obvious errors here. What exactly is the problem? What line of code
>fails? Is there an error reported or does it just leave the box empty?
>What happened when you stepped through the code in the debugger? What
>other methods have you tried? What happened when you did a Google
>search about the error message? Did you ever set up the connection
>properties? Is the database query working? Is the database plugged in
>and running? Is this an ASP app or a Windows application? Etc
>Etc Etc
>
>Debugging of other people's code is 100 bucks an hour, and I probly
>should charge more. Help with a specific error or problem is what
>mailing lists are for.
>
>Jasmine
>
In CSharpNET (AT) yahoogroups (DOT) com, Shahid Riaz Bhatti
><risky_bhatti@wrote:
>
Hi Hasan
Y dont u use DataTable as DataSource 4 the Combo box.?
It will solve ur problem.
Shahid Riaz Bhatti
hassan1980eg <hassan1980eg@wrote:
Hi all
o people of expert in C# please aid me in this problem
whats wrong with this segment of code
i want to accomplish this task dynamically
the comobobox cannot be fill with this code i declared the
sqlDataReader as book says and i draged the sqlCoammand and
sqlConnection from tool box i tried with sotredProcdeure and
CommandText with no result when i try to write it static i supply
the name of instructor it works whats wrong please help
thanks in advance
private void Form3_Load(object sender, System.EventArgs e)
{
sqlC();
sqlCommand3.Parameters["@instructor"].Value= (this.Text.Substring
(7)).ToString();//beaware this.text is the form caption for example
Welcome Hamid like i'm trying to trim 7 chars to get the name of user
--
//sqlCommand1.CommandText="SELECT * FRM Table2 WHERE Instructor='"+
(this.Text.Substring(7)).ToString()+"'";
//MessageBox.Show(());
//sqlCommand1.CommandText="SELECT * FRM Table2 WHERE
Instructor='Hamid'";
();
//comboBox1.Items.Clear();
while (sqlDataReader1.Read())
{
comboBox1.Items.Add(sqlDataReader1["Course"].ToString());
--
}
--
sqlDataReader1.Close();
sqlConnection2.Close();
--
}
>
>
>
>
>
>
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail.
[Non-text portions of this message have been removed]
>
>
>
>
>
Live the life in style with MSN Lifestyle. Check out!
Yahoo! Groups Links
<*To visit your group on the web, go to:
<*Your email settings:
Individual Email | Traditional
<*To change settings online go to:
(Yahoo! ID required)
<*To change settings via email:
mailto:CSharpNET-digest (AT) yahoogroups (DOT) com
mailto:CSharpNET-fullfeatured (AT) yahoogroups (DOT) com
<*To unsubscribe from this group, send an email to:
CSharpNET-unsubscribe (AT) yahoogroups (DOT) com
<*Your use of Yahoo! Groups is subject to: