473,406 Members | 2,894 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,406 software developers and data experts.

Executing a SQL2005 Stored Procedure

In running vb.net 2003 and am trying to run a stored procedure

Dim InputString() As String
InputString = Split(InputParm, ";")
' set the query commands
STR_SQLCOMMAND.CommandText = "BossData.dbo.OperatorLogon"
STR_SQLCOMMAND.CommandType = CommandType.StoredProcedure
STR_SQLCOMMAND.CommandTimeout = 30
With STR_SQLCOMMAND
' Set the 1st Parameter
.Parameters("@OperatorName").Value = InputString(0)
.Parameters("@OperatorPassword").Value = InputString(1)
.Parameters("@PasswordLife").Value = InputString(2)
End With

The Connection to the Database is already set as SQL_CONNECTED
i got so far but dont know how to execute it or get the return ..... Help
Jun 13 '06 #1
3 1326
Hello,
See if this helps:

Dim sqlConn As New SqlConnection(gstrSqlConn)
Dim sqlComm As New SqlCommand("EXECUTE StoredProcedureName", sqlConn)

'Open the sql connection
sqlConn.Open()
Dim sqlDReader As SqlDataReader = sqlComm.ExecuteReader()

While sqlDReader.Read()
'Obtain values from each row here...
gstrOperatorName = CStr(sqlDReader("OperatorName")).Trim
End While

Jun 13 '06 #2
This is what your looking for:

Dim Reader as SqlDataReader
Dim cmdSQL as SqlCommand
Dim Conn as New SqlConnection(strconn)

cmdSQL = New SqlCommand
Conn.Open()

With cmdSQL
.CommandText = "SVTN_EDI_EXCEPTIONS"
.CommandType = CommandType.StoredProcedure
.Connection = Conn
.Parameters.Add("@DOC_ID", SqlDbType.VarChar, 30).Value
= DocID
.Parameters.Add("@EXCEPTIONDESC", SqlDbType.VarChar,
50).Value = ExceptionDesc
.Parameters.Add("@IDENTITY_COL", SqlDbType.Int,
4).Value = IdentityCol
Reader = .ExecuteReader()
End With

While Reader.Read
'row data is accessed through the reader. For example "Reader(0)"
End While

Reader.Close()
Conn.Close()

If the sp returns a single value then use "variable = .ExecuteScalar"
instead.
IdleBrain wrote:
Hello,
See if this helps:

Dim sqlConn As New SqlConnection(gstrSqlConn)
Dim sqlComm As New SqlCommand("EXECUTE StoredProcedureName", sqlConn)

'Open the sql connection
sqlConn.Open()
Dim sqlDReader As SqlDataReader = sqlComm.ExecuteReader()

While sqlDReader.Read()
'Obtain values from each row here...
gstrOperatorName = CStr(sqlDReader("OperatorName")).Trim
End While


Jun 13 '06 #3
Peter,

In addition to the others, the main thing you are missing is as Izxy showed
as well.
.CommandType = CommandType.StoredProcedure

After that you can decide if you use an
executenonscalar 'to return one value
a datareader 'to return one row and set the cursor to the next to get the
next
a dataadapter (or from that inherited tableadapter) 'to get a complete
resultset as table (which is using the datareader behind the scene)

Cor

"Peter Newman" <Pe*********@discussions.microsoft.com> schreef in bericht
news:8A**********************************@microsof t.com...
In running vb.net 2003 and am trying to run a stored procedure

Dim InputString() As String
InputString = Split(InputParm, ";")
' set the query commands
STR_SQLCOMMAND.CommandText = "BossData.dbo.OperatorLogon"
STR_SQLCOMMAND.CommandType = CommandType.StoredProcedure
STR_SQLCOMMAND.CommandTimeout = 30
With STR_SQLCOMMAND
' Set the 1st Parameter
.Parameters("@OperatorName").Value = InputString(0)
.Parameters("@OperatorPassword").Value = InputString(1)
.Parameters("@PasswordLife").Value = InputString(2)
End With

The Connection to the Database is already set as SQL_CONNECTED
i got so far but dont know how to execute it or get the return ..... Help

Jun 13 '06 #4

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

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
1
by: rvdw | last post by:
Hi All, I've a serious problem with executing stored procedures (SQL2000) from an Access db (version 97). After executing a stored procedure , msaccess hangs. The whole call to the procedure is...
0
by: harry | last post by:
Hi, I'm getting an exception when I debug stored procedure on SQL2005 System.InvalidOperationException was unhandled Message="The requested operation requires a SqlClr context, which is only...
9
by: Nemisis | last post by:
Hi everyone, hope your all looking forward to xmas. I am setting up a Sql2005 database on a Windows Server, running Windows Server 2003. The database is going to be accessed via users using an...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
0
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...

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.