web 2.0

VB.NET & System.Data.OracleClient - Parameter Query (OracleParameter)

VB.NET & System.Data.OracleClient - Parameter Query (OleDbParameter) - How to learn Connector/NET ADO.NET component  System.Data.OracleClient namespace is the .NET Framework Data Provider for Oracle data source, Using the OracleParameter for mapping to a DataSet column (Oracle Server Database)

ShotDev Focus:
- VB.NET & System.Data.OracleClient - Parameter Query (OleDbParameter)

Example

ParameterQuery.aspx

<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OracleClient"%>
<%@ Page Language="VB" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)
Sample1()
End Sub

Sub Sample1()

Dim objConn As System.Data.OracleClient.OracleConnection
Dim objCmd As System.Data.OracleClient.OracleCommand
Dim strConnString,strSQL As String

strConnString = "Data Source=TCDB;User Id=myuser;Password=mypassword;"
objConn = New System.Data.OracleClient.OracleConnection(strConnString)
objConn.Open()

'*** FOR INSERT ***'
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " & _
"VALUES (:sCustomerID,:sName,:sEmail,:sCountryCode,:sBudget,:sUsed)"

objCmd = New System.Data.OracleClient.OracleCommand(strSQL,objConn)
With objCmd
.Parameters.Add(new OracleParameter(":sCustomerID", "C005"))
.Parameters.Add(new OracleParameter(":sName", "Weerachai Nukitram"))
.Parameters.Add(new OracleParameter(":sEmail", "webmaster@shotdev.com"))
.Parameters.Add(new OracleParameter(":sCountryCode", "TH"))
.Parameters.Add(new OracleParameter(":sBudget", "2000000"))
.Parameters.Add(new OracleParameter(":sUsed", "100000"))
End With
objCmd.ExecuteNonQuery()

lblText.Text = "Record Insert Sucessful."

'*** FOR UPDATE ***'
'strSQL = "UPDATE customer SET Budget = :sBudget " & _
'" WHERE CustomerID = :sCustomerID "

'objCmd = New System.Data.OracleClient.OracleCommand(strSQL,objConn)
'With objCmd
'    .Parameters.Add(new OracleParameter(":sBudget", "4000000"))
'     .Parameters.Add(new OracleParameter(":sCustomerID", "C005"))
'End With
'objCmd.ExecuteNonQuery()

'*** FOR DELETE ***'
'strSQL = "DELETE FROM customer  " & _
'" WHERE CustomerID = :sCustomerID "

'objCmd = New System.Data.OracleClient.OracleCommand(strSQL,objConn)
'With objCmd
'    .Parameters.Add(new OracleParameter(":sCustomerID", "C005"))
'End With
'objCmd.ExecuteNonQuery()

objCmd = Nothing
objConn.Close()
objConn = Nothing

End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="Server"></asp:Label>
</form>
</body>
</html>

Screenshot

VB.NET & System.Data.OracleClient - Parameter Query (OleDbParameter)
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.