473,795 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's wrong with this C# connection?

76 New Member
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.O pen();
CommandSql.Comm andText = sql;
CommandSql.Conn ection = ConnectionSql;
QueryResult = CommandSql.Exec uteReader();
return (QueryResult[colIndex].ToString());
}
}
Aug 5 '06 #1
0 1318

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

Similar topics

1
3593
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 following line commented, so it does not activate, I can successfully print all of the response.write's below: rsGroup.Open strSQL, adoCon
2
2120
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 anything wrong with my connection string?(if something left?) Thanks Charles Shao =================================================================
3
1908
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 and at the remote client computer on the File>Connection>Data link properties I'm using an IP address for the server name which I got from the LOG file of MSDE (192.168.xxx.xx,1433) but then I realised that that IP could not be used to connect...
10
2265
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 * from projeto order by nome" cmd.Connection = conn conn.Open() dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
4
1178
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 New OleDb.OleDbCommand dc.Connection = cn
0
4765
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 for a connection string wihout DSN using IBM DB2 OLE PROVIDER in windows environment, but unfortunately, I found none. The DB2 connection string in http://www.connectionstring.com/ is wrong:
2
1550
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 by noisy cube-mates, they can code during whichever hours work for them (with the help of IM and email), and so on. Many of us are lucky enough to live this lifestyle; I include myself in this set, as I've been a full time telecommuter for...
167
8367
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 object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++ doesn't have such functionality, say in its STL. This absence of a thread/object relationship in...
0
2041
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 Godaddy, I have point "A (Host) Record" to my IP and the "MX Record" is also pointing to my IP. I have tested sending e-mail from my gmail.com account to my server, the server receive e-mails from gmail.com to my /home/andre/mbox successfully. ...
0
4544
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 will be highly appreciated. First, the error that I am getting when I try to connect to the remote host after performing NODE and database catalog is the following: SQL1336N The remote host "WINSVR2008R2-2" was not found. SQLSTATE=08001. I...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.