Click here to Skip to main content
15,887,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
By clicking the submit button the data from datagrid should be inserted into the table.

What I have tried:

My connection class file:
Imports System.Data.OracleClient
Imports System.Data
Public Class connection
Public conn As OracleConnection
Private constatus As String
Sub setonstatus(ByVal values As String)
Try
If values = "open" Then
conn.Open()
End If
Catch ex As Exception
ex.GetBaseException()
End Try
Try
If values = "close" Then
conn.Close()
End If
Catch ex As Exception
connection.FnMessageAlert(Me, ex.Message, "msg")
End Try
End Sub

Private Shared Sub FnMessageAlert(ByVal connection_Class As connection, ByVal p2 As String, ByVal p3 As String)
Throw New NotImplementedException
End Sub
Public Sub New()

conn = New OracleClient.OracleConnection("DataSource=---;user id=---;password=---;unicode=true")
End Sub
ReadOnly Property getconstatus() As String
Get
constatus = conn.State.ToString()
Return constatus
End Get
End Property
Public Shared Function getconnection() As OracleConnection
Dim varconn As OracleConnection
Dim varcmd As OracleCommand
varcmd = New OracleCommand
Dim varstrconn As String
varstrconn = "Data Source=---;User id=---;Password=---;unicode=true"
varconn = New OracleConnection(varstrconn)
If varconn.State = ConnectionState.Closed Then
varconn.Open()
End If
Return varconn
End Function
End Class

SQL procedure:
CREATE OR REPLACE PROCEDURE insertproduct(
p_pid pack_product.pid%TYPE,
p_pname IN pack_product.pname%TYPE,
p_unitprice IN pack_product.unitprice%TYPE)
IS
BEGIN
INSERT INTO pack_product(pid,pname,unitprice) VALUES (p_pid, p_pname,p_unitprice);
COMMIT;
END;

How can I link this procedure to store all rows in datagrid to pack_product table?
Posted
Updated 30-Mar-16 4:09am

1 solution

I would look up 'calling an oracle stored procedure c#' - this may give you a kick-start

.net - Calling Oracle stored procedure from C#? - Stack Overflow[^]

- once you know how to do that, then, you loop for all the rows of your datagrid, calling the stored procedure, passing the data for each of the 3 columns to the stored procedure
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900