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

How to use ADO command object to get a record set via stored procedure?

As the title,
I have a simple stored procedure just input a index and return a row,
how can I get the return record by in my VB.Net application using ADODB
Object 2.5?

Jul 10 '06 #1
4 1756

here a simple ADO.Net example

Public Function GetSomeData(ByVal Id As Decimal) As DataTable
GetSomeData = New DataTable
Using con As New SqlConnection(My.Settings.MyConnectionString)
Using cmd As New SqlCommand("Myproc", con)
cmd.CommandType = CommandType.StoredProcedure
Dim par As SqlParameter = cmd.Parameters.Add("@ParA1",
SqlDbType.Decimal)
par.Value = Id
Dim da As New SqlDataAdapter(cmd)
da.Fill(GetSomeData)
End Using
End Using
End Function

regards

Michel Posseth [MCP]

"Cylix" wrote:
As the title,
I have a simple stored procedure just input a index and return a row,
how can I get the return record by in my VB.Net application using ADODB
Object 2.5?

Jul 10 '06 #2
Thanks M. Posseth.

I going to try in ADO.NET now,
one more simple question, can you tell me the connection string in
ADO.NET

example data here:

DB: sqlserver2000
location: 10.0.0.123
UID: USERNAME
PID: password
Database name: MYDB

Please advise.

Jul 10 '06 #3
The connection string would be :

For SQL Server Authentication, use this syntax specify a user name and
password, where asterisks represent a valid user name and password.
"Persist Security Info=False;User ID=*****;Password=*****;Initial
Catalog=AdventureWorks;Server=MySqlServer"
Use this syntax to connect using an IP address, where the network library is
Win32 Winsock TCP/IP and 1433 is the port being used (the default).

Network Library=dbmssocn;Data Source=000.000.000.000,1433;
SQL Server allows you to use the following network libraries when
establishing a connection.

dbnmpntw
Win32 Named Pipes

dbmssocn
Win32 Winsock TCP/IP

dbmsspxn
Win32 SPX/IPX

dbmsvinn
Win32 Banyan Vines

dbmsrpcn
Win32 Multi-Protocol (Windows RPC)

for copy paste examples see

http://www.connectionstrings.com/
regards

Michel Posseth [MCP]


"Cylix" wrote:
Thanks M. Posseth.

I going to try in ADO.NET now,
one more simple question, can you tell me the connection string in
ADO.NET

example data here:

DB: sqlserver2000
location: 10.0.0.123
UID: USERNAME
PID: password
Database name: MYDB

Please advise.

Jul 10 '06 #4
Thanks Posseth ,

I have another problem during fill the datatable,
it returns system error in the error message,

Is it problem in my stored procedure?

My SP is really simply, just select a record(1 row) in a table by an
index, eg

CREATE PROCEDURE dbo.std(@uid char(12)) AS
Select studentName from student where studentID=@sid
GO

Jul 11 '06 #5

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

Similar topics

2
by: Stefan Berglund | last post by:
I was looking for a general consensus as to whether the ActiveConnection property of the command object should be set to Nothing or whether it's sufficient to set the command object itself to...
5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
1
by: Eric Land | last post by:
Help! I'm trying to call a parameterized stored proc in ASP.NET in VB. I am creating a command object and creating a parametr list, and assigning a value from a session variable (this is working)...
7
by: John Walker | last post by:
Hi, In order to have my application give the best performance, I'm trying to design my ASP.NET page where I will only have to populate my DataReader once. It is a simple application where we...
5
by: Bari Allen | last post by:
I'm trying to test for concurrency, using a SQL Stored Procedure on a RowVersion (timestamp) Field. The vb code I'm using is as follows Dim cmd As New SqlCommand("ConcurrencyCheck", cn) Dim...
1
by: ILCSP | last post by:
Hello, I'm trying to accomplish 3 things with one stored procedure. I'm trying to search for a record in table X, use the outcome of that search to insert another record in table Y and then exec...
8
by: Ivan | last post by:
Hi I am new in DB2, and I have some problems when I try run stored procedures, and others statements. I made one stored procedure very simple, but this show different messages. I have followed...
4
by: enggwaqas | last post by:
I have an Oracle stored procedure that takes approx 3 minutes to execute and I am using .net 2.0 data access provider for oracle. Now i want to cancel the execution of stored procedure from .net...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
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...
0
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,...

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.