hi every body!
I use Oracle and for connection management I use OLEDB, the problem is where I want to do Update. the Update command is generated by an OleDBDataAdapter as the code below:
Public Sub UpdateData(ByVal oiDataSet As DataSet, ByVal siSQL As String, Optional ByVal siTableName As String = Nothing)
Dim oDataAdapter As New OleDbDataAdapter
If mbPiDisposed = True Then
Throw New ObjectDisposedException(msPiModuleName, "This object has already been disposed. You cannot reuse it.")
oDataAdapter.SelectCommand = New OleDbCommand(siSQL, mcnPiConnection, mtrPiTransaction)
Dim oCommandBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(oDataAdapter)
If siTableName = Nothing Then
Catch ex As Exception
Throw New Exception(msPiExceptionMessage, ex)
when I call this Sub (I pass a simple "SELECT * FROM TABLE_NAME" and Updated data as "oiDataSet" to the OleDBDataAdapter as shown above) this error is shown: "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information"
I searched the Internet But every one said that you may have not define a primary key, but my table has one!!
I should say the INSERT commands are OK, the problem is with UPDATE and DELETE commands.
every suggestion would be appreciated
At a guess I would say that your select statement does not include the primary key for the table.
As a general recommendation I suggest you learn about Data Access Layer (DAL) and not rely on the adapter auto generation tools, you will be a better developer faster if you understand the tools you are using.
thank you for reply,
yes I have not the Where Clause in my statement. if it was my choice, yes! as you said, it's the worst way to let the tools do the job!! but this code was a part of an old, big and critical project which my boss prefers not to change the code unless it's necessary!!! so I want to be sure there is not any other way except using "Where" and pass primary keys!! so I can content the boss to change the code!!
by the way thanks for your kind recommendation,
ANOTHER HELP EQUEST: do you know any other way??;) (my boss is so hard!)
I found where is the problem.
after all discussions, about how can sombody send an Update command to data base!!! the key is here:
Every thing was ok in code and table difinitions. just in connection string a property should be defined: "OLEDB.NET=True"
Using the Entity Framework, when creating an entity model based on those tables I get the error:
Foreign key constraint 'FK_UserContractCompanies_TimesheetContractEntries' has been omitted from the storage model. Column 'CompanyId' of table 'SMSModel.Store.UserContractCompanies' is a foreign key participating in multiple relationships. A one-to-one Entity Model will not validate since data inconsistency is possible.
The intended business logic is to have a subset of users as contract users. A contract user arrives at the workplace, can sign in (an entry is made in the TimesheetEntries table), work for X hours and then sign out. For any user that is a contract user, the TimesheetContractEntries table exists to record their times broken into two records. The first record would be start and end times showing the first 8.5 hours of work, without a related ContractCompanyId, and the second record would be the remaining time with a related ContractCompanyId.
I'm using VS 2010 Beta 2, and have tried including foreign key columns in the model. Is the schema of my database flawed or is there anyway to overcome this limitation in the EF?
I have to store hindi,chinese ... etc language words in my db
What is the problem? A string of characters has no meaning to the database, it is just characters, so you can store any language you like. It is only when you extract those characters from the database and display them that they have any meaning, e.g. a message read by a human operator.
how can i do the language conversion from HINDI to english ... any sourcecode?
Some pseudo code
var ctrlValue=value; //Variable ctrlValue stores the value of the respective languages depinding on the offset value var english="";
for (var idx=0; idx<ctrlValue.length; idx++)//Loop Until The End Of Text Is Reached
individualChar = ctrlValue.substring(idx,idx+1); //Extracting Charecter 1 By 1 From The String Valuevar code =individualChar.charCodeAt(0);//Gets the Unicode Value
english=english+ String.fromCharCode(code-offset);//Converts From Other Language Values To Englishswitch(offset)
case2358:document.getElementById('txtEnglish').value=english;break;//For Hindi Value To English
Sorry for not getting an appropriate code for your help. I will update as and when I will get the code for oracle for serving the same purpose.
I recently put MSSQL Server 2005 on my server running Windows 2003...it went off perfectly. I decided to replace the MSSQL 2000 that I was running on my desktop (Win XP) as well. Unfortunately, although it said that there were no errors, the Server Management Studio does not appear in the program files (or anyplace else) that I can find. The only links that appear are for the Server Configuration and the Surface Area Configuration. I tried to do a new install (on top), but the application said that all components were already installed. Before I remove the installed app and start all over, I want to know if I am missing something? Somewhere? All assistance is greatly appreciated. Pat
Thank you for taking the time to respond. My install was a full Enterprise edition. I did figure out the problem and wish to share it with you (and others) because it is especially important to anyone that has installed a version of SQL 2005 Express or MS Visual Studio 2008, which automatically installs the express version. When installing over a previously installed version, any new install must be done from a DOS prompt using an update command on the command line. If this is not done, it will see the previous version as being successfully installed and will skip the install of the Database server. I have done this and it is now working perfectly. Of course, it took me the better part of a day to figure it out. Hopefully, this might save someone else that trouble. Thank you again and happy coding....Pat
In my ASP.NET application I have the dashboard.
Number of records needs to be fetched from database into it. Hence,I want to write stored procedure which gives me these records using multiple Select statements. Is it possible to fetch it? If yes how it can be done.
Alter Procedure GetMultipleRecords
-- First select
Select * from test1
-- Second select
Select * from test2
So this will give u two record sets
Step 2: Use Data Adapter & DataSet
From Asp.net application, by usingDataAdapter get the records setinto the DataSet
Step 3: Use respective datatable(s) from DataSet
Get the record sets from the DataSet into DataTable(some pseudo code in c#)
DataSet ds = getDataRecords();->You will get the records from database
if(ds!=null && ds.tables.count > 0)
//Store the result for Select * from test1 into datatable firstDt
DataTable firstDt = ds.tables;
//Store the result for Select * from test2 into datatable secondDt
DataTable secondDt = ds.tables;
Hope you get the idea.
Now try by urself and I am sure you will reach the point.
declare @tbl table(id int identity, refid int)
insert into @tbl
select0 union all select1 union all
select2 union all select1 union all
select1select t.id,t.refid,casewhen x.cnt isnull then 0else x.cnt end as total
from @tbl t
select refid,count(refid) as cnt
where refid <> 0group by refid
having (count(refid)>0)) x
on t.id = x.refid
id refid total
Last Visit: 31-Dec-99 19:00 Last Update: 4-Dec-23 18:25