473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

need some help, driving me nuts

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_C onnection=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

Nov 15 '05 #1
1 1106
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" <cs*********@sbcglobal.net> wrote in message
news:eV****************@TK2MSFTNGP11.phx.gbl... 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_C onnection=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

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: b_prikls | last post by:
Hi all, i need your help, here is code, that makes http connection to a website throu a proxy server, and it works fine: ========================================== $proxy = "111.111.111.111";...
3
by: Steve Kreis | last post by:
Somebody help. The bloggers are driving me nuts. They are direct linking to images on my site thus driving up my traffic to an artificially high level. What I would like to do is prevent them from...
55
by: Alex | last post by:
Hello people, The following is not a troll but a serious request. I found myself in a position where I have to present a Pro/Con list to management and architects in our company with regard to...
0
by: Christopher Ambler | last post by:
This is long, but it's driving me nuts. I need some adult supervision :-) (and I'm not above bribing for help) I have a stored procedure that I call that returns XML to me. The SP returns 3...
3
by: RWC | last post by:
Hello, I have an issue that's driving me batty! I have a report, whose record source is SQL based on a normalized set of tables. There are no nested queries and no dlookups in this record...
12
by: Marty | last post by:
It seems all of the sudden that user controls that contain images are referencing image sources relative to the document that I drop the control on. This obviously does not work beacuase the...
6
by: Benjamin Walling | last post by:
We have 109 remote offices all running Sybase ASA Server. We collect data from these offices and consolidate it into our main server. I have written a program that will read from each office and...
14
by: mat | last post by:
Hi all, This is weird and it is driving me nuts, please can someone explain how I can get it to return the correct answer: print '$_SESSION: '.$_SESSION.'<br />'; print '$_SESSION:...
0
by: Billie Boy | last post by:
Hi to all. I’m new here and am coming to you from Melbourne Australia. So a big HELLO 2 ALL. Now I am encountering an annoying problem in the SQL builder of the copy of VB.6 that I am using at...
3
by: DuncanIdaho | last post by:
Hello experts IE 7.0.5730.11 Opera 9.27 Firefox 2.0.0.14 This problem only occurs in Opera and Firefox (amazing, IE does something right, or maybe not) Anyway, the problem is that when I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.