so this code works with just the out parameter but then when you add in parameters weird nulls start showing up and also the straight in parameters work too so it is just when there are both in and out parameters. and i have tried the out parameter at end and beginning of parameter list
the part with problems is the in and out parameters do not want to coexist -
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
-
For Each kvp As KeyValuePair(Of String, String) In sqlParams
-
Dim newParam As New OracleParameter(kvp.Key, OracleDbType.Varchar2, kvp.Value, Data.ParameterDirection.Input)
-
newParam.Size = 400
-
cmd.Parameters.Add(newParam)
-
Next
-
This works - Public Shared Sub Run_Oracle_Query(ByVal queryToRun As String, ByVal sqlParams As Dictionary(Of String, String))
-
Dim dbConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ITSS").ConnectionString
-
Dim con As OracleConnection = New OracleConnection(dbConnString)
-
Dim cmd = con.CreateCommand()
-
Try
-
con.Open()
-
cmd.CommandText = queryToRun
-
cmd.CommandType = CommandType.Text
-
For Each kvp As KeyValuePair(Of String, String) In sqlParams
-
cmd.Parameters.Add(kvp.Key, kvp.Value)
-
-
Next
-
cmd.ExecuteNonQuery()
-
'log all sql queryies very expensive operation
-
LogThisString("Log All queries: " & queryToRun, "Always")
-
Catch ex As OracleException ' catches only Oracle errors
-
OracleExceptionLogging(ex.Number, queryToRun, ex)
-
Catch ex As Exception
-
LogThisString("General Error SQL: " + ex.Message.ToString(), "Always")
-
' MsgBox("Could Not Perform This Database Operation")
-
Finally
-
con.Close()
-
cmd.Dispose()
-
con.Dispose()
-
End Try
-
End Sub
-
This works - Public Shared Function Run_Insert_Oracle_Query_Return_ID(ByVal queryToRun As String, ByVal IDcolumnName As String) As String
-
Dim dbConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ITSS").ConnectionString
-
Dim con As OracleConnection = New OracleConnection(dbConnString)
-
Dim cmd = con.CreateCommand()
-
Dim strUkey As String = ""
-
Try
-
con.Open()
-
cmd.CommandText = queryToRun & " RETURNING " & IDcolumnName & " INTO :UKEY"
-
cmd.CommandType = CommandType.Text
-
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
-
cmd.ExecuteNonQuery()
-
strUkey = cmd.Parameters("PKEY").Value.ToString
-
Return strUkey
-
Catch ex As OracleException ' catches only Oracle errors
-
OracleExceptionLogging(ex.Number, queryToRun, ex)
-
-
Catch ex As Exception
-
LogThisString("General Error SQL: " + ex.Message.ToString(), "Always")
-
PopupMsgBox("Database Error", "Database Integrity Constants Violated SQL Operation Will Not Be Executed")
-
Finally
-
con.Close()
-
cmd.Dispose()
-
con.Dispose()
-
End Try
-
-
Return strUkey
-
End Function
-
This does not work - Public Shared Function Run_Insert_Oracle_Query_Return_ID(ByVal queryToRun As String, ByVal IDcolumnName As String, ByVal sqlParams As Dictionary(Of String, String)) As String
-
-
Dim dbConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ITSS").ConnectionString
-
Dim con As OracleConnection = New OracleConnection(dbConnString)
-
Dim cmd = con.CreateCommand()
-
Dim strUkey As String = ""
-
Try
-
con.Open()
-
cmd.CommandText = queryToRun & " RETURNING " & IDcolumnName & " INTO :UKEY"
-
cmd.CommandType = CommandType.Text
-
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
-
For Each kvp As KeyValuePair(Of String, String) In sqlParams
-
Dim newParam As New OracleParameter(kvp.Key, OracleDbType.Varchar2, kvp.Value, Data.ParameterDirection.Input)
-
newParam.Size = 400
-
cmd.Parameters.Add(newParam)
-
Next
-
cmd.ExecuteNonQuery()
-
strUkey = cmd.Parameters("PKEY").Value.ToString
-
Return strUkey
-
Catch ex As OracleException ' catches only Oracle errors
-
OracleExceptionLogging(ex.Number, queryToRun, ex)
-
-
Catch ex As Exception
-
LogThisString("General Error SQL: " + ex.Message.ToString(), "Always")
-
PopupMsgBox("Database Error", "Database Integrity Constants Violated SQL Operation Will Not Be Executed")
-
Finally
-
con.Close()
-
cmd.Dispose()
-
con.Dispose()
-
End Try
-
-
Return strUkey
-
End Function
1 2580
crap so i guess it does look for order asnd the output does need to be at end like this.....this works solved my own problem -
For Each kvp As KeyValuePair(Of String, String) In sqlParams
-
Dim newParam As New OracleParameter(kvp.Key, OracleDbType.Varchar2, kvp.Value, Data.ParameterDirection.Input)
-
newParam.Size = 400
-
cmd.Parameters.Add(newParam)
-
Next
-
cmd.Parameters.Add("PKEY", OracleDbType.Int64, ParameterDirection.Output)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: siva |
last post by:
Hi,
I saw your post on oracleParameterCollection Bug in MSDN
news groups reg: OracleParameterCollection and
OracleCommand bug.
|
by: JWM |
last post by:
I am trying to implement Oracle connection pooling for the following code,
which was written by someone else. Here is my main question -- this java
file creates code that is executed every hour,...
|
by: JBBHF |
last post by:
Hi i'm working on a web project, and i would like to make my oracle
query work in mysql.
select match.numero "nummatch",
to_char(match.datematch, 'yyyy-MM-dd') "datematch",
p1.numjoueur "j1",...
|
by: Michael B Allen |
last post by:
I have a general purpose library that has a lot of checks for bad input
parameters like:
void *
linkedlist_get(struct linkedlist *l, unsigned int idx)
{
if (l == NULL) {
errno = EINVAL;...
|
by: tshad |
last post by:
I have the following code:
***************************************************************************
Dim CommandText as String = "INSERT INTO ftsolutions.dbo.position
(client,dateposted) VALUES...
|
by: cetram |
last post by:
Hello!
I'm trying to fix an appliaction created using ColdFusion MX and Oracle 9i. The application worked fine until our IT department reinstalled the oracle server. As far as I've been able to...
|
by: vbDavidC |
last post by:
I am adding a new record to an Access table. This is a sample table
with only 1 field which is a primary key. I can add the record ok if
it is not a dup (or null). I am trying to learn the...
|
by: BillCo |
last post by:
I'm new to SQL Server, so if I'm doing anything stupid don't be
mean :)
I have a procedure that I use to return data based on optional
parameters. It works fine, except when the underlying data...
|
by: pbaillard |
last post by:
Here a sample to call a stored procedure with an Oracle Database.
odc.Connection = m_cDb ' use an open connection to your database
odc.CommandType = CommandType.StoredProcedure
odc.CommandText =...
|
by: Ruslan A Dautkhanov |
last post by:
Hello !
I'm about to install O9i on FreeBSD box.
uname -a:
FreeBSD stat2.scn.ru 5.2.1-RELEASE-p3 FreeBSD 5.2.1-RELEASE-p3 #2:
Fri Apr 23 19:19:43 KRAST 2004...
|
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,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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,...
|
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...
|
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...
| |