Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tableadapter query parameters

Status
Not open for further replies.

JasonSummers

Programmer
Sep 11, 2002
26
US
I have a Listview control on my form that is filled with data from a table (Main_Table). Right clicking a row on the listview opens up a form (my edit data form))with data fields (connected to a dataset ) for editing. I pass the 'Task Number' (the record number or item number) value to this form and I would like the value passed to a parameter I have in my fillby query. I created by fillby query by right clicking the tableadapter>Add Query. The Query looks like this.

SELECT Item_No, Item_Name, Item_Description, Priority, Percent_Complete, Closed, Reference_Information, Date_Initiated, Date_Required, Date_Statused, Date_Completed, Primary_Contact
FROM Main_Table
WHERE (Item_No = @TaskNumber)


On my data entry form load event I would like to pass the TaskNumber string into this query as follows, but I do not understand the available documentation on about parameters.

private void DataEntry_Load(object sender, EventArgs e)
{
this.main_TableTableAdapter.FillBy(this.dsdworgDataSet.Main_Table,TaskNumber);
}

How do I use the parameter in the query? This does not work. Also, why does everyone use the @ sign when working with parameters? I'm so confused.


Thanks for your help.
Jason
 
this may help []
also google TableAdapters, ado.net Command Parameters, ado.net command, and ado.net overview. this will also give you more background info on how data adapters work.

basically what you want is a "shortcut" for the FillBy() function. this additional function must be created at design time, so at runtime your code knows what to do.

The @ symbol denotes a sql variable. @ is most commonly used, because most .net systems are attached to an MS SQL Server. Different dbs have different variable delimiters. I belive Oracle uses : as a delimiter for variables.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
jmeckly,

Thank you for the microsoft link, it was a provided most of the information I was looking for. Your reply was greatly appreciated.


JAson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top