I am in C#.net2005
I have a listbox bound to a dataset, in the dataset, I built a new query:
SELECT ServiceID, ProductDetails, ServiceNotes, ServiceCharge, DeliveredDate, CustomerName FROM [Freedom Scooter Service Reminder]
WHERE CustomerName = "@CNAME" AND DeliveredDate IS NULL
in Code, I want to give value to this parameter"@CNAME" , so that the listbox will show the records with given CustomerName.
by the way, the value of "@CNAME" I want to get from is comboBoxCusName.SelectedValue.ToString()
plz help

how to give value to parameter in a query of dataset in C#.net2005?
joehammond
hi Itzik, all done, it's my first C#.net project, actually the first time I work with C language, the code of this app is very simple, just wanted to make myself feel comfortable with C. Anyway, I simply wonldn't be able to progress without all the helps I got here, especially Itzik, you know what, the motivation behind the helps is the most important part.
thx all for the help and I am sure I will be asking more questions soon, (I am planning to give a touch on classes building and ASP.net next)
cheers
Monscheuer
hi Itzik, I will try to fix it myself one more night, I will email u the solution if I still cant fix it in the morning.
btw, my db is Access db, uses oledb, the parameter might be set in a different way
cheers
Mads Torgersen
hi Itzik, cant believe u still here while I went to bed already, thx soo much for your patience.
Anyway, I tried it already without the ", it threw error:
General Selected Statement. Error in WHERE clause near "@". Unable to parse query text.
then I changed it back, added the ", no error when "finish" is clicked. However, It still doesnt take 2 arguments in the adapter.fillByCNPending
btw, r u using .net2003 or 2005 cos I use 2005
P3T3R 7
Cy Harper
SibfordChris
Hey man
just got home
i write exactly the example in anew project:
query:
SELECT CandidateID, SSID, Title, FirstName, MiddleName, LastName
FROM CandidatesTbl
WHERE (FirstName = @FName)
code:
adapter.FillByCName(
this.ds_main.CandidatesTbl,"Itzik");now this is so basic that you might have a silly mistake like using the wrong adapter or not using the generate query wizard correct, so please get someone else to llok at the procees as you create the query i am sure he will find a mistake.
in T-SQL basically you do FirstName='Itzik' but when using parameters you do not need to use '
try to create an empty project go through the steps as needed and i am sure that you will succeed to create a 2 parameter fill method
is there a way you can send me the solution to:
rocksrabbit@gmail.com and i will take a look
Good luck
gatalec
ok, well, it doesnt work here,
the query is for FillByCNPending is:
SELECT ServiceID, ServiceDeliveredDate, CustomerName, FROM [Freedom Scooter Service Reminder]
WHERE (CustomerName = "@CNAME")
AND (ServiceDeliveredDate IS NULL)
my code is:
this.TableAdapterCusV.FillByCNPending(this.dataSetCusV.Freedom_Scooter_Service_Reminder,comboBoxCusName.SelectedValue.ToString());
when i run the app, it throws error:
No overload for method 'FillByCNPending' take '2' arguments
plz help (if any one is awake, plz)
Muhammad Ismael
try
SELECT ServiceID, ServiceDeliveredDate, CustomerName, FROM [Freedom Scooter Service Reminder]
WHERE CustomerName = @CNAME AND ServiceDeliveredDate IS NULL
Do not use the " when using parameters
beside on the last wizard screen the wizard tells u if the select query is ok and if it is not ok then he does not create the method with the two parameters. so check that u do not have a warning on the last wizard screen (you can do this by right click on the query in the adapter and then select configure... and then click next until the last screen and see if there is any warning anyway change the query as i mention)
Hope it does the trick, if not i will answer you again tomorrow morning
Goos night
HJOak
Hey I am terribly SORRY I did not see you are working in access
Here is the solution
SELECT ID, FirstName FROM UsersTbl
Where FirstName =
this.usersTblTableAdapter.FillByParameter(this.dbDataSet1.UsersTbl, "Shamo");
Here is an article on the subject
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpguide/html/cpconusingparameterswithdataadapters.asp
Look in oledb
Again sorry
Itzik
MartinRoyds
hi Itzik, there is nothing to be sorry for, I should be the one that appreciate all the help from u, and it is great way of learning for me. really, thx very very much. now I try to apply these changes, c if I can make it work. it's almost done, once I finish it, I will give u a copy of my app, just for fun.
cheers
Mhorn821
Hello again i gave you an example in the last thread you opened
adapter.FillByCandidateID(
this.powerJobsDataSet.CandidatesTbl, 1);This works with the query
select * from CandidatesTbl where CandidateID = @CID
in my case @CID = 1 as you can see
as you can see our dear microsoft supplied agreat mechanism which retrieves the parameter in the fill method parameter list
so you just need to write
if(comboBoxCusName.SelectedValue != null)
youradapter.fillByWhateverYoucallit(table name, comboBoxCusName.SelectedValue.ToString())
Hope i understand your question
if you want something else do it quick cause I am going to sleep
Javier Peña
well, I used the built-in query builder, the auto generated query WHERE clause is:
WHERE (CustomerName = '@CNAME') AND (ServiceDeliveredDate IS NULL)
however, the error No overload for method 'FillByCNPending' take '2' arguments still exists, no idea how to fix it..... I will keep trying.
lxhvc
is there anything wrong with my use clause, should I use something like System.Data.sql
btw, my using clauses are:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
I added this line, it still not working:
using System.Data.OleDb;
Mathijs van Bockhooven
I am fine thx Itzik, I feel bad holding u up~
It's 5:28 am over here, I am about to go to bed too, cheers
have a good night/morning