473,320 Members | 2,020 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,320 software developers and data experts.

How can I write a true SELECT statement?(for accsesing and using a data in database)

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4. SqlConnection dbCon = new SqlConnectio(connectionstring);
  5. SqlCommand sqlCom = new SqlCommand();
  6. sqlCom.CommandText = "SELECT FROM rizha";//comment:rizha is a table
  7.      try
  8.     {
  9.     SqlDataReader dr;
  10.     dbCon.Open();
  11.     dr = sqlCom.ExecuteReader();
  12.     if (dr.HasRows == true )
  13.     {//comment:I run with break piont and I undrestand this line never run in debuging and i dont know why?
  14.  
  15.         textBox7.Text  = (String)dr["tnine"];
  16.     }//comment:"tnine" is a record
  17.         dr.Close();
  18.         dbCon.Close();
  19.  
  20.     while (dr.Read())
  21.     {
  22. textBox7.Text=textBox7.Text+ (dr["tnine"]).ToString();
  23. //comment:use textBox to access data    
  24.  } 
  25.  
  26. }
  27. catch (Exception ex)
  28.  { } 
  29.  
  30.   }
  31.  
  32.  
Jan 14 '11 #1
1 1234
Christian Binder
218 Expert 100+
You missed a *
SELECT * FROM rizha
Jan 14 '11 #2

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

Similar topics

0
by: Rob Sirota | last post by:
Hello, I am having a problem when doing a SELECT. Here is the scenerio: I have a table that has an event StartDate and EndDate, based on the current Date "NOW()" I need to know which records...
1
by: schildr | last post by:
I hope I posted this to te correct forum How do I put something like the following in a Select statement for the Crystal Viewer JOSD_JOHN NOT IN (select JOHN from RATE_DATA I tried...
4
by: Chris | last post by:
Hello, I am attempting to build a MS SQL query that will return data from "today"; today being current day 8:00AM-10:00PM today. My goal is to return the data from a table that is written to...
4
by: Michel Esber | last post by:
Hello, DB2 LUW V8 FixPack 13. create table Table (ID varchar(20), USED char) I need to find out the total row count per ID, as well as the row count where USED=Y. I could do this with a...
2
by: sohaildkm | last post by:
name of the table I WANT TO WRITE THE QUERY IN SQL,Data base is db2 1-migrated customer relator table this table contains mamsi migrated customer where migrated company code is =MAM,I wat to run...
3
by: sangam56 | last post by:
Hello!I am using following sql statement: SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE Menu.MenuID= (SELECT Permissions.MenuID FROM Permissions WHERE Permissions.RoleID=(SELECT Roles.RoleID...
2
by: Donna Horton | last post by:
If I create a Select statement to select a username and userid from a table then I want to select the userid from another table and sort on the userid for example I sorted on the email usernames and...
2
by: Jmaes Wang | last post by:
Let’s say we have 3 tables: fruit name, color and taste that have data like this: Fruits: Apple Color: Red Green Yellow
1
by: ncsthbell | last post by:
Once again... I am supporting another Access database that I did not build. The previous 'owner' of this built the tables with spaces in the table names as well as the column names. I am having a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.