473,396 Members | 1,760 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,396 software developers and data experts.

Read just one row (primary key) and display each column of the row

I am using Postgresql in VS 2013 and C#.

I use this for the reading of just one row by primary key.

string p has the users id it must look for in the table.

Expand|Select|Wrap|Line Numbers
  1.  cn.Open();
  2.  selectSql = "SELECT user_id,user_name,user_password,user_administrator FROM userlogon WHERE user_id ='" + p + "'";
  3.  cmd.CommandText = selectSql;
  4.  NpgsqlDataAdapter da = new NpgsqlDataAdapter(selectSql, conn);
  5.  NpgsqlCommandBuilder cdb = new NpgsqlCommandBuilder(da);
  6.  DataSet ds = new DataSet();
  7.  DataTable dt = new DataTable();
  8.  ds.Reset();
  9.  da.Fill(ds);                 
  10.  dt = ds.Tables[0];           
  11.  
I now want the first column of the row to be moved to another string like:

Expand|Select|Wrap|Line Numbers
  1. got_userID = dt.Columns[0].ToString();
  2.  
But all I get is literally the field's name, 'user_id' in got_userID when I display it via messageBox.Show!

Any idea why?

Thanks!
Oct 16 '15 #1
0 2567

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Westcoast Sheri | last post by:
Which will be a faster lookup of an item by, "color" in the following mySQL tables: "unique key," "primary key," or just plain "key"?? CREATE TABLE myTable ( number int(11) NOT NULL default '0',...
1
by: Lannsjo | last post by:
I need to change my primary key column type from smallint to int. I have tried: ALTER TABLE livegroup MODIFY id INT UNSIGNED NOT NULL AUTO_INCREMENT; But get an error message certainly since my...
1
by: blanch | last post by:
Hi all, I'm pretty new to MySQL, but have some Access background. I've created a table for which I intended the email column to be the primary key, but didn't specify it at creation. Now, I'm...
4
by: Mavis Tilden | last post by:
Hi all, So I've been reading the newsgroups, and reading a few books trying to learn SQL and SQL Server 2000. The books tell me I need a Primary Key, and that every table should have one. I know...
4
by: Peter Scott | last post by:
I created a table that has a column in that needs to contain a full Unix file path. Since 2048 was too long for a VARCHAR, I made it TEXT. I since populated the table. Now I want to make the...
2
by: stranger | last post by:
My database is set up so people can input parts orders. Sometimes they order the same parts on a monthly basis. I want to be able to duplicate past parts orders and have it pasted in with a new...
3
by: Leon Shaw | last post by:
How do I get the primary key of a record just enter into the database? Then pass that same primary key ID column value to another table? Example: --- Members Table --- ---Transaction...
0
by: bvdrsganesh1981 | last post by:
Hi All There are 2 Tables: Tables are : Tbl1 ( 1col1,1col2,1col3,1col4) and Tbl2 ( 2col1,2col2,2col3) In Tbl1 (1col1,1col2,1col3 ) are composite primary key.So...
6
by: sachin | last post by:
Hi, I am facing some strange issue in DB2 UDB 9.5.1 I have created a database on DPF implemented environment and I tried to execute following commands Db2 create table test ( name char(10)...
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:
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.