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

What's wrong with this C# connection?

76
Please tell me what's wrong with this picture.

Expand|Select|Wrap|Line Numbers
  1.  
  2. public class MyClass
  3.     {
  4.         SqlConnection       ConnectionSql = null;
  5.         SqlCommand          CommandSql = null;
  6.         SqlDataReader         QueryResult = null;
  7.  
  8.         public MyClass(string dbString)
  9.         {
  10.             ConnectionSql = new SqlConnection(dbString);
  11.             CommandSql = ConnectionSql.CreateCommand();
  12.             CommandSql.Connection = ConnectionSql;
  13.         }
  14.  
  15.  
public string ReturnSomething(string sql, int colIndex)
{
ConnectionSql.Open();
CommandSql.CommandText = sql;
CommandSql.Connection = ConnectionSql;
QueryResult = CommandSql.ExecuteReader();
return (QueryResult[colIndex].ToString());
}
}
Aug 5 '06 #1
0 1301

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

Similar topics

1
by: iam247 | last post by:
Hi I have a web page which receives information from a form (using request.form) and also attempts to look at an Access query to read in recoeds to a variable named rsGroup. When I have the...
2
by: Charles shao | last post by:
Hi dear friends: I have a DB and I want to access it through ODBC. I can create a DataGrid in disigner and it works well. But I failed when trying to open connection manually. Are there...
3
by: GAVO-UK | last post by:
Experts I'm experimenting with ADP and MSDE and I'm trying to connect a remote front end through the internet. I have already enabled TCP/IP connection on port 1433 on the MSDE host computer...
10
by: Daniel Sélen Secches | last post by:
I was trying to make a simple dataReader.... Sub projets() Dim conn As New OleDbConnection(connstring) Dim dr As OleDbDataReader() Dim cmd As New OleDbCommand() cmd.CommandText = "select *...
4
by: Hyphessobrycon | last post by:
Private Sub btnrubriekbij_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrubriekbij.Click 'insert hier Dim cn As New OleDb.OleDbConnection(constr) Dim dc As...
0
by: alingsjtu | last post by:
What's the DB2 connection string wihout DSN when use IBM DB2 OLE PROVIDER in windows environment, such as ADO or Creation of Linked Server in MS SQL Server ? I searched for a long time to look...
2
by: estherschindler | last post by:
For a lot of IT people -- everyone from software developers to tech writers to network support folks -- telecommuting is the best personal option. They get a flexible schedule, they aren't bothered...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: lopes80andre | last post by:
Hi, I'am trying to configure a Postfix server to send e-mails by SMTP using the SMTP server of my ISP. I have made a Postfix installation as "Internet with Smarthost". I'am using a domain in...
0
by: okonita | last post by:
Hi all, I am having a DB2 connectivity problem that I hope someone can help me resolve. I need this to test Replication and such other things. What am I doing wrong here? Any help that I can get...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.