need some help, driving me nuts

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a web page that displays contact people in a drop down.
the users selects a person then clicks the go button.
The datagrid should pop with all the information on the select contact
person, correct?

Well, now my issue. I have 5 contact names in the drop down, (pop from DB)
when I select one nothing happens except for one name. I only get
information back for only one person, nothing happens if i select a
different name. The grid comes back blank, but is populated if I pick a
certain name. What would cause this to happen?

here is the code for the drop down.
if (!IsPostBack)
{
SqlDataAdapter myCommand = new SqlDataAdapter("select distinct
contact_person from Authors", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "contact_persons");
MySelect.DataSource= ds.Tables["contact_persons"].DefaultView;
MySelect.DataBind();
}

code for the grid:
public void GetTask_Click(Object sender, EventArgs E)
{
String selectCmd = "select * from authors where contact_person =
@contact_person";

SqlConnection myConnection = new
SqlConnection("server=server;database=db;Trusted_Connection=yes");

SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);

myCommand.SelectCommand.Parameters.Add(new SqlParameter("@contact_person",
SqlDbType.NVarChar, 2));
myCommand.SelectCommand.Parameters["@contact_person"].Value =
MySelect.SelectedItem.Value;

DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");
MyDataGrid.DataSource= ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
}
since this code correctly agains the pubs db authors table, i took that
table and put it in my Database to verify it wasn't a db issue, that worked
fine, when took that table and made column name changes, and data changes -
nothing. I only get information for 1 person.

need help

thnx
 
what value are you getting from this statement:
myCommand.SelectCommand.Parameters["@contact_person"].Value =
MySelect.SelectedItem.Value;

I haven't looked at your database, but is 'contact_person' defined as an
NVarChar(2) field, because that's what you are sending to the query.

If so, does your dropdown just show a list of these short values?

That's where I'd look if I were you.
--- Nick

Mike said:
I have a web page that displays contact people in a drop down.
the users selects a person then clicks the go button.
The datagrid should pop with all the information on the select contact
person, correct?

Well, now my issue. I have 5 contact names in the drop down, (pop from DB)
when I select one nothing happens except for one name. I only get
information back for only one person, nothing happens if i select a
different name. The grid comes back blank, but is populated if I pick a
certain name. What would cause this to happen?

here is the code for the drop down.
if (!IsPostBack)
{
SqlDataAdapter myCommand = new SqlDataAdapter("select distinct
contact_person from Authors", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "contact_persons");
MySelect.DataSource= ds.Tables["contact_persons"].DefaultView;
MySelect.DataBind();
}

code for the grid:
public void GetTask_Click(Object sender, EventArgs E)
{
String selectCmd = "select * from authors where contact_person =
@contact_person";

SqlConnection myConnection = new
SqlConnection("server=server;database=db;Trusted_Connection=yes");

SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);

myCommand.SelectCommand.Parameters.Add(new SqlParameter("@contact_person",
SqlDbType.NVarChar, 2));
myCommand.SelectCommand.Parameters["@contact_person"].Value =
MySelect.SelectedItem.Value;

DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");
MyDataGrid.DataSource= ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
}
since this code correctly agains the pubs db authors table, i took that
table and put it in my Database to verify it wasn't a db issue, that worked
fine, when took that table and made column name changes, and data changes -
nothing. I only get information for 1 person.

need help

thnx
 
Back
Top