473,473 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1129
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
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
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...

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.