P
Peter
Hi, there
I have created an stored procedure using the DDL below for my MS Access
Database and no error occurs. Also it can create an stored procedure if I
changed the parameter from "[zSampleName]" to ""@zSampleName".
OleDbcmd.CommandText = _
"CREATE PROCEDURE udpGetSampleIDByName" & vbCrLf & _
"([zSampleName] VarChar(64))" & vbCrLf & _
"AS" & vbCrLf & _
"Select zSampleID FROM T1 " & _
"Where zSampleName =[zSampleName]"
OleDbcmd.ExecuteNonQuery()
Then I called the stored procedure like this. What bothered me these days is
: The tempID always got the same value "1" no matter what parameter value I
set (a, b or c).
With OleDbcmd
.Connection = connNoTran' This is an active oledbconnection
.CommandType = CommandType.StoredProcedure
.CommandText = "udpGetSampleIDByName"
.Parameters.Add("[zSampleName]", OleDbType.VarChar)
.Parameters(0).Value = "a"
dim tempID as integer
Dim dr as new OleBbDataReader = OleDb.ExecuteReader
If dr.Read() Then
tempID = sdr(0)
Else
tempID = 0
End If
A sample of T1 table is:
zSampleName(primary key) zSampleID
a 1
b 2
c 3
d 4
. .
. .
. .
Thanks in advance
'---------------------------------------------------------------------------
---------------
Background:
All my codes have been tested under SQL Server2000 and VB.NET last month.
But I decided to turn to MS Access after reading many stuffs from internet.
Because my project is a desktop program and it doesn't need to consider
concurrence. Due to the one file mechanism MS Access has many advantages in
terms of ease of deployment and maintenance.
Peter
I have created an stored procedure using the DDL below for my MS Access
Database and no error occurs. Also it can create an stored procedure if I
changed the parameter from "[zSampleName]" to ""@zSampleName".
OleDbcmd.CommandText = _
"CREATE PROCEDURE udpGetSampleIDByName" & vbCrLf & _
"([zSampleName] VarChar(64))" & vbCrLf & _
"AS" & vbCrLf & _
"Select zSampleID FROM T1 " & _
"Where zSampleName =[zSampleName]"
OleDbcmd.ExecuteNonQuery()
Then I called the stored procedure like this. What bothered me these days is
: The tempID always got the same value "1" no matter what parameter value I
set (a, b or c).
With OleDbcmd
.Connection = connNoTran' This is an active oledbconnection
.CommandType = CommandType.StoredProcedure
.CommandText = "udpGetSampleIDByName"
.Parameters.Add("[zSampleName]", OleDbType.VarChar)
.Parameters(0).Value = "a"
dim tempID as integer
Dim dr as new OleBbDataReader = OleDb.ExecuteReader
If dr.Read() Then
tempID = sdr(0)
Else
tempID = 0
End If
A sample of T1 table is:
zSampleName(primary key) zSampleID
a 1
b 2
c 3
d 4
. .
. .
. .
Thanks in advance
'---------------------------------------------------------------------------
---------------
Background:
All my codes have been tested under SQL Server2000 and VB.NET last month.
But I decided to turn to MS Access after reading many stuffs from internet.
Because my project is a desktop program and it doesn't need to consider
concurrence. Due to the one file mechanism MS Access has many advantages in
terms of ease of deployment and maintenance.
Peter