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

Connecting in a database

Hi all !
I´m with a problem to make a connection in my application.
I´m in VB.net, and using a sql2000 database. When I´m try
to connect to database, I can open the connection, but
can´t execute a stored procedure. My code is:
<code>
Dim objConn as New SqlConnection("Password=123;User
Id=sukist;Initial Catalog=DBMedium;Data
Source=DBSMEDIUMDEV;")
Dim objCmd as sqlCommand
Dim myDataReader as sqldatareader

objCmd = New sqlCommand("SP_GET_LIST")
objCmd.commandtype = commandtype.storedprocedure

myDataReader = objCmd.Execute
(CommandBehavior.CloseConnection)

</code>

The error message is: Login failed for user 'sukist'. But
the error occurs in the line which execute the command.
And if a I try to connect in Query Analyzer, using the
same information of my connectionString, the connection
opens sucefully. Anybody can help me with this?

TIA, Sukist!
Jul 21 '05 #1
2 1126
Hi Sukist,
Use the ExecuteReader method of the command object rather
than the Execute method.
I hope this works. My email has 2 "k"s in it. Have a
great day!! Carol
-----Original Message-----
Hi all !
I´m with a problem to make a connection in my application.
I´m in VB.net, and using a sql2000 database. When I´m try
to connect to database, I can open the connection, but
can´t execute a stored procedure. My code is:
<code>
Dim objConn as New SqlConnection("Password=123;User
Id=sukist;Initial Catalog=DBMedium;Data
Source=DBSMEDIUMDEV;")
Dim objCmd as sqlCommand
Dim myDataReader as sqldatareader

objCmd = New sqlCommand("SP_GET_LIST")
objCmd.commandtype = commandtype.storedprocedure

myDataReader = objCmd.Execute
(CommandBehavior.CloseConnection)

</code>

The error message is: Login failed for user 'sukist'. But
the error occurs in the line which execute the command.
And if a I try to connect in Query Analyzer, using the
same information of my connectionString, the connection
opens sucefully. Anybody can help me with this?

TIA, Sukist!
.

Jul 21 '05 #2
Make sure you ExecuteReader() and then make sure you do something like
while(dr.Read()){
//DoSomething.

}
"Sukist" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi all !
I´m with a problem to make a connection in my application.
I´m in VB.net, and using a sql2000 database. When I´m try
to connect to database, I can open the connection, but
can´t execute a stored procedure. My code is:
<code>
Dim objConn as New SqlConnection("Password=123;User
Id=sukist;Initial Catalog=DBMedium;Data
Source=DBSMEDIUMDEV;")
Dim objCmd as sqlCommand
Dim myDataReader as sqldatareader

objCmd = New sqlCommand("SP_GET_LIST")
objCmd.commandtype = commandtype.storedprocedure

myDataReader = objCmd.Execute
(CommandBehavior.CloseConnection)

</code>

The error message is: Login failed for user 'sukist'. But
the error occurs in the line which execute the command.
And if a I try to connect in Query Analyzer, using the
same information of my connectionString, the connection
opens sucefully. Anybody can help me with this?

TIA, Sukist!
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
4
by: CodeImp | last post by:
A simple app I quickly wrote to try getting info from a database. Here is the first part of its code. The rest of the code is irellevant. using System; using System.Data; using...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
5
by: Sebastian | last post by:
I'm using the following code to connect to an access 2000 database. (with reference to adodb) Public DBvar As New ADODB.Connection() DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data...
3
by: GTDriver | last post by:
I'm trying to connect my application with a web service located on my own web server(localhost). I guess when the solution/proect is built it makes a file called 'Web...
5
by: nielsgron | last post by:
Hi, I have created a database on DB2 8.1 and 8.2 for Windows using the codeset "Big5" with the command: db2 CREATE DATABASE TWBIG5 USING CODESET BIG5 TERRITORY TW When I try to connect to...
5
by: Odd Bjørn Andersen | last post by:
I have installed DB2 9 Enterprise Edition on my laptop and created the sample database. Now I'm having truble connecting to the database from Command Editor. If I connect from Command Window it's...
0
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've my win32 application which connecting to my sql database. till now i used MSDE as my database and now i want to upgrade to sql express 2005. after the upgrade i tried to connect to the...
3
by: Sebouh | last post by:
Hi guys. I'm completely new to databases, so i wanna ask you if this is achievable. I've been learning how to connect to an MS SQL database file with java. I've finally learned the basics,...
2
by: bobt1991 | last post by:
I just installed Microsoft Visual Studio 2008 Express edition, and it installs some sort of stripped down version of SQL Server. It comes with no tools for connecting to your "local" database,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...
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.