Q: query of dataadapter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have a SqlDataAdapter component in my design. Is there a way to send a
parameter to the query of SqlDataAdapter, I need go get adapter use a where
clause and extract data. Is it possible?
Thanks,
Jim.
 
Brock,
I am new in this, can you give me a link or a code example?
Thansk,
Jim.
 
SqlDataAdapter da = new SqlDataAdapter("select * from authors where au_id
= @id", connString);
da.SelectCommand.Paramaters.Add("@id", "222-33-4444");
DataSet ds = new DataSet();
da.Fill(ds, "MyTable");

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Thanks Brock,
My dataadapter, sqlconnection and dataset are already in my application as
components, so I am not defining a new sqladapter in the code, can still
change the query and refresh dataset?
Thanks,
Jim.
 
Ah, you've just encountered some of the problems with Drag & Drop ;)

I never use the visual-goo for my DB work. As you can see, it's just as quick
to write those 4 lines of code than it is use whirl the mouse around the
screen... ((oops, I'm starting to sound pedagogical))

Anyway, I don't see why you can't change the code that's been gen'd for you.
At the end of the day, it's just code. But you will have to make sure before
you use the DB goo that you've added in the parameter and its value.

HTH

-Brock
DevelopMentor
http://staff.develop.com/ballen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top