meers1974
asked on
updating database (oracle) through a dataadapter
I have a SQL Server stored procedure that retrieves abt. 10 rows of data for 3 tables
I have retrieved this inside a dataset (there will be totally 3 tables)
I pass each of the table to a function in which I build a InsertCommand for a Dataadapter.
And I add parameters:(one of the functions below)
parameters-obj_conn, objdata_tbl, objTrans
Try
obj_adap = New OleDb.OleDbDataAdapter()
obj_adap.InsertCommand = New OleDb.OleDbCommand()
obj_adap.InsertCommand.Com mandText = _
"Insert into MARKET_HIST " & _
"values (?, ?, ?)"
obj_adap.InsertCommand.Con nection = objConn
obj_adap.InsertCommand.Par ameters.Ad d(New OleDb.OleDbParameter("@ID" , OleDb.OleDbType.Integer))
obj_adap.InsertCommand.Par ameters.It em(0).Sour ceColumn = "ID"
obj_adap.InsertCommand.Par ameters.Ad d(New OleDb.OleDbParameter("@HIS T_ID", OleDb.OleDbType.Integer))
obj_adap.InsertCommand.Par ameters.It em(1).Sour ceColumn = "HIST_ID"
obj_adap.InsertCommand.Par ameters.Ad d(New OleDb.OleDbParameter("@DT_ BOUGHT", OleDb.OleDbType.Date))
obj_adap.InsertCommand.Par ameters.It em(2).Sour ceColumn = "DT_BOUGHT"
obj_adap.InsertCommand.Tra nsaction = objTrans
i = obj_adap.Update(objdata_tb l)
For some reason, the parameters are not populated...
ie., If I print obj_adap.InsertCommand.com mandtext, I only get
Insert into MARKET_HIST values(?, ?, ?)
I do not get the actual values..
Can someone help me with this?
I have retrieved this inside a dataset (there will be totally 3 tables)
I pass each of the table to a function in which I build a InsertCommand for a Dataadapter.
And I add parameters:(one of the functions below)
parameters-obj_conn, objdata_tbl, objTrans
Try
obj_adap = New OleDb.OleDbDataAdapter()
obj_adap.InsertCommand = New OleDb.OleDbCommand()
obj_adap.InsertCommand.Com
"Insert into MARKET_HIST " & _
"values (?, ?, ?)"
obj_adap.InsertCommand.Con
obj_adap.InsertCommand.Par
obj_adap.InsertCommand.Par
obj_adap.InsertCommand.Par
obj_adap.InsertCommand.Par
obj_adap.InsertCommand.Par
obj_adap.InsertCommand.Par
obj_adap.InsertCommand.Tra
i = obj_adap.Update(objdata_tb
For some reason, the parameters are not populated...
ie., If I print obj_adap.InsertCommand.com
Insert into MARKET_HIST values(?, ?, ?)
I do not get the actual values..
Can someone help me with this?
Why dont you use command builder rather than creating manual insert command.
Vikas
Vikas
ASKER
Vikas,
Can you help me use the command builder?
Where can I find information abt. it?
Thanks.
Can you help me use the command builder?
Where can I find information abt. it?
Thanks.
ASKER
I tried the .net data provider.
Still I have the above problem. The Insert command has to build properly inorder for me to go to performance issues.. The Insert command is not building properly. As I said, the parameters do not get populated.. Any ideas?
Still I have the above problem. The Insert command has to build properly inorder for me to go to performance issues.. The Insert command is not building properly. As I said, the parameters do not get populated.. Any ideas?
See the example of oracle .net data provider
Dim da As OracleDataAdapter = New OracleDataAdapter()
Dim cmd As OracleCommand
Dim parm As OracleParameter
' Create the SelectCommand.
cmd = New OracleCommand("SELECT * FROM Dept " & _
"WHERE DName = :pDName AND Loc = :pLoc", conn)
cmd.Parameters.Add("pDName ", OracleDbType.NVarChar, 14)
cmd.Parameters.Add("pLoc", OracleDbType.NVarChar, 13)
da.SelectCommand = cmd
' Create the InsertCommand.
cmd = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _
"VALUES (pDeptNo, pDName)", conn)
cmd.Parameters.Add("pDeptN o", OracleDbType.Number, 2, "DeptNo")
cmd.Parameters.Add("pDName ", OracleDbType.NVarChar, 14, "DName")
da.InsertCommand = cmd
Return da
End Function
Dim da As OracleDataAdapter = New OracleDataAdapter()
Dim cmd As OracleCommand
Dim parm As OracleParameter
' Create the SelectCommand.
cmd = New OracleCommand("SELECT * FROM Dept " & _
"WHERE DName = :pDName AND Loc = :pLoc", conn)
cmd.Parameters.Add("pDName
cmd.Parameters.Add("pLoc",
da.SelectCommand = cmd
' Create the InsertCommand.
cmd = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _
"VALUES (pDeptNo, pDName)", conn)
cmd.Parameters.Add("pDeptN
cmd.Parameters.Add("pDName
da.InsertCommand = cmd
Return da
End Function
before this you need to create a connection
ASKER
I do have a connection. I have only posted a part of the code.
I have fixed the problem. I had to add an "AcceptChangesDuringFill = False" statement to the dataadapter.
It works fine now.
Thanks for your time.
I have fixed the problem. I had to add an "AcceptChangesDuringFill = False" statement to the dataadapter.
It works fine now.
Thanks for your time.
Okay what about by points
Okay what about my points
ASKER
Hi
Your answers did not help me.
The real problem was to add the line:
AcceptChangesDuringFill = False
I did not see that in your code. So, I did not give the points.
If you insist I'll definitely award the points. No problems.
Thanks
Your answers did not help me.
The real problem was to add the line:
AcceptChangesDuringFill = False
I did not see that in your code. So, I did not give the points.
If you insist I'll definitely award the points. No problems.
Thanks
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
PAQ with points refunded
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
TheLearnedOne
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
PAQ with points refunded
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
TheLearnedOne
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
see the link
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/manprooracperf.asp
The .net data provider for oracle is more faster than oledb data provider
Try to use this