Hi All- I've been browsing for a while but finally had to sign up to ask a question. I'm working on a little project that pulls data from a few places, Active Directory, ADAM, and an Informix Database. I've got my ODBC drivers installed and I've got my Data source set up properly and I have finally (after reading through much here) got it returning some results.

[quickie info]
VS2008
XP 32bit
Informix CSDK 3.0
[/quickie info]


So, I added a query under the databasename.xsd page (actually modified the Fill() command) of one table. I want the SQL to be as follows:

SELECT     ss_no
FROM        "informix".id_rec
WHERE     (id = idnum)

Where idnum is a variable in my C# windows form application. If I hard code the query to say

(id= "39923")

I get the valid ss_no field for that ID.

So, how would I go about this? I've tried adding it to the Parameters Collection, but I can't figure out what to do with it from there..

2nd part:
I want to take what I return and put it into a variable (no problem... can handle that, I've set it to execute scalar and get a string back, I can cast it to what i need to do with it) but then I need to do an UPDATE command also with a variable included (so, same principal, two problems)


Any help would be much is appreciated, let me know if you need any code scraps!

Chris

Hi,
use this command
SqlCommand commandd=new SqlCommand("SELECT ss_no FROM "informix".id_rec WHERE id ="+txtBox1.Text+"",connection );
here txtBox1 is where you are giving your input in your Form.Similarly Update command also.
I hope this helps you.
Regards,
Narra.

Hi All- I've been browsing for a while but finally had to sign up to ask a question. I'm working on a little project that pulls data from a few places, Active Directory, ADAM, and an Informix Database. I've got my ODBC drivers installed and I've got my Data source set up properly and I have finally (after reading through much here) got it returning some results.

[quickie info]
VS2008
XP 32bit
Informix CSDK 3.0
[/quickie info]


So, I added a query under the databasename.xsd page (actually modified the Fill() command) of one table. I want the SQL to be as follows:

SELECT     ss_no
FROM        "informix".id_rec
WHERE     (id = idnum)

Where idnum is a variable in my C# windows form application. If I hard code the query to say

(id= "39923")

I get the valid ss_no field for that ID.

So, how would I go about this? I've tried adding it to the Parameters Collection, but I can't figure out what to do with it from there..

2nd part:
I want to take what I return and put it into a variable (no problem... can handle that, I've set it to execute scalar and get a string back, I can cast it to what i need to do with it) but then I need to do an UPDATE command also with a variable included (so, same principal, two problems)


Any help would be much is appreciated, let me know if you need any code scraps!

Chris

Thanks for the help, I've not tried including using System.Data.SqlClient; and doing it that way. If I could figure out how to get data back and forth that way it'd certainly make more sense to me.. It's much more the style of SQL work I'm used to (PHP / MySQL). Now I need to figure out how to set up my connection so it works... I see lots of examples for MSSQL but I'm a little confused how to use my already available data source to do this..

I was hoping for a way to do this I saw floating around the VB.net forum, but I can't find it again... :S thanks for the suggestion, I'll see if I can get this working...

Chris

How to make a datasource need a video to explain it I recommend you go to www.msdn.com and search on How Do I C# you'll find some examples.

Try to use paramatized command better than including parameter in command string!!

Let me rephrase.. I HAVE a datasource.. it's working fine.. I set the Fill() Query to do what I want, I just can't get parameters to work.. I can pull all the information I need to, I just can't get a parameter into my query.. I've attached some pictures and code to hopefully help explain where I'm at...
[img]http://pages.usiouxfalls.edu/chuthe/daniweb/1.gif[/img]

So there I've got my data source set up and the tables set up.. the Fill() method you see in id_rec points to this:

SELECT     ss_no
FROM         "informix".id_rec
WHERE     (id = "136883")

Now, where (id="136883") I want 136883 to be a variable from my form.

here is my C# on my form:

CARSDATATableAdapters.id_recTableAdapter idrec2 = new JICS_Account_Peaker.CARSDATATableAdapters.id_recTableAdapter();
string st1;
st1 = idrec2.Fill();
psswdlbl.Text = st1;

and that works fine, pulling just what i want, if only I could pass in a variable...

hope this helps-

chris

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.