|
To get the last identity value you need to execute a
select @@identity
command. I don't know if ADO.NET will do this automatically for you or if you have to do it yourself.
Dave.
|
|
|
|
|
Thank you for the answer.
Is there no way that I get the wrong id? When another table is updated after my update statement and before I can use "select @@identity"?
|
|
|
|
|
You will be OK as long as you don't have any triggers on the table you are updating that also do inserts. If you have triggers, use Chris' option below.
select @@identity returns the last identity value generated in the current session (which is why triggers with inserts can cause issues), so as long as your session doesn't do any other inserts you are OK.
Dave.
|
|
|
|
|
If you're using SQL Server then use
SELECT IDENT_CURRENT('TableName')
This will return the latest Identity value for the Table called 'TableName'.
cheers,
Chris Maunder
|
|
|
|
|
I am writing a database program using ADO and Visual C++.
Let me explain my problem.
m_pConn->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=Inventory.mdb;",
L"", L"", adOpenUnspecified );
...
pRs->Open( _variant_t( bstrQuery ),
vNull,
adOpenDynamic,
adLockOptimistic,
adCmdUnknown );
if( m_pRs->Supports( adDelete ) && m_nNoRows > 1 )
{
m_pRs->Delete( adAffectCurrent );
m_pRs->MoveNext();
if( m_pRs->GetADOEOF() )
m_pRs->MovePrevious();
}
CString strFilter = "vField LIKE 'smth%';
m_pRs->Filter = _variant_t( (_bstr_t)strFilter );
//
After I set the filter and I delete a record, if I try to
move to the previous record (even though the record is not
the first) I get an error which suggests that the row where
I am trying to move is either marked for deletion or has
been deleted. Why? The database supports MovePrevious and
I don't use batch mode. This problem occurs only if I
set a filter. The filter works fine too. It selects only
the records that I want it to select.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I have a function within an Oracle database that performs a simple multiplication or division of two data points that the function will query for. The result of the function is then returned to the caller. I have recently become aware that in just about all cases the number being returned is always a five decimal number with correct rounding, but I really require it to return all decimals, or as many as it keeps track off. As a demonstration of the difficulty the following shows an example
select 1.2345 / 1.1111 from dual
1.2345/1.1111
-------------
1.11106111
In this case some kind of truncation occurs, but at least 8 decimals are returned (the 06111 just continues to repeat). Now if I expand the number of decimals for one of the numbers
select 1.2345 / 1.111111 from dual
1.2345/1.111111
---------------
1.11105011
Once again 8 decimals. But now I try
select 1.2345 / 1.11111111 from dual
1.2345/1.11111111
-----------------
1.11105 Why only the five decimals? I need to figure out what are the unique circumstances that are causing the return to limit to five decimals. Any one with some ideas to look at or suggestions, I'll be happy to hear them. Thanks.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.
|
|
|
|
|
First of all my assumption is that your precision is set to 8 (8 digits after the decimal point). I don't know what you're doing and to tell you the truth I don't know how to change it because I have never used Oracle. But I can tell you this.
All the calculations that you have shown are correct. You get different results because 1.2345 is being divided by 3 different numbers and that's what the precision shows you.
1.1111 is a different number from 1.111111
The last division
1.2345/1.11111111 = 1.1110500011110500011110500011111 and if you truncate it you get 1.11105000 (the precision is 8). You know that the last zeros are irrelevant so your answer is 1.11105.
Of course it depends on your application how accurate you want to be.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
I have written a stored procedure that is called once for each machine in the data table per shift change. Each machine has 200+ records--one for each output. Each output has a code for the material being produced. The stored procedure copies this code from the previous shift data.
Occasionally! the first time the procedure is called after shift change it will copy the codes for about half of the machine and leave NULL in the remaining records. The rest of the machines always appear to have copied successfully.
Any suggestions on how to fix this problem? Either within the SP or the calling code doesn't matter.
Thanx...
>>>-----> MikeO
|
|
|
|
|
You are using terminology in your question that I don't understand. What do you mean by machine? What machine are you talking about? What do you mean by shift change? You are going to have to either explain more about the problem domain (e.g. what a machine/shift change refers to, etc.) or you are going to have to re-phrase your question as a pure database related question (e.g. I am using this sproc (provide code) which gets to a certain point in the process and then dies or inserts nulls when valid fields exist. What's happening?). Send some code and ask your question a bit differently and you'll probably get the answer you need.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi..
I have a table which includes 2 datetime fields. One is Start_DTM, the other is Finish_DTM. It's for employee hours. My typical day would be
Start_DTM Finish_DTM
(date)09.00 (date)13.00
(date)13.00 (date)14.00
(date)14.00 (date)17.00
So, you see it records *everything* including breaks. If I do a SELECT query
where start_DTM or Finish_DTM = (date) then I get the above info.
Of course things get complicated.
Lets say I work a night shift.... like
Start_DTM Finish_DTM
(date)20.00 (date)23.00
(date)23.00 (date+1)01.00
(date+1)01.00 (date+1)04.00
(date+1)04.30 (date+1)05.00
Now... as far as my boss is concerned, I worked from 9pm til 4am on (date).
(Disregard the 4.30 to 5am as it didn't follow on from 4 am)
So when I look for work done on (date) I should also bring back anything
recorded into the next day under certain conditions:
Where there is a record which *starts* on (date) and *finishes* on (date+1),
I have to retrieve that record (the straddle record). Then, I look to see if any other records have a Start_DTM which is identical to the Finish_DTM of
the straddle record. If I do, I take that record's Finish_DTM and try to
find a record which has a Start_DTM identical to that record's Finish_DTM.
Once the continuation stops, the query stops. Hence, I disregard the record
that has Start_DTM (date+1)04.30 because it is later than any previous Finish_DTM that can link it back to (date).
Still with me? congrats!
So.. I am aware of various conditional T-SQL (IF...ELSE, WHILE etc) but
these seem to base their conditions on single items (like an average < 15).
I would like to write a stored procedure to get this data. At the moment, all
I can think of is to set up a temporary table (SQL Server 2000) and add
records to it as I see fit (or add 3 days data and remove as see fit).
I am not aware of how temporary tables affect performance. My goal is
to have a DataAdapter which runs the stored procedure to fill a dataset,
which I will ultimately bind to a WinForms control....
What are my chances? Any tips greatly appreciated!!!
Cheers
John
|
|
|
|
|
Does anyone know where I can find a technical specification for dBASE IV? I looked on www.inprise.com but could not find one. I need to write a program which parses/writes/creates dBASE IV tables (.dbf).
Thanks,
Mark Sanders
sanderssolutions.com
|
|
|
|
|
I used the CodeBase engine for that (don't know a link). On the plus side, it links staticly into your app, it is small, and it is fast. On the down side, the API is unfriendly, but a nice class wrapper solved that problem.
|
|
|
|
|
|
I'm a dBase Specialist. Tell me please what you exactly need to write your programm. Perhaps I can help...
Stefan
|
|
|
|
|
I have an ASP.NET application accessing a SQL Server database. Worked fine last night, this morning I am getting the following error continuously:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.SqlClient.SqlConnection.Open() at MyService.DataService.AuthenticateUser(String DomainUsername) in \\Eoctstliciis01\CREQSERVICE\DataService.asmx.vb:line 169 --- End of inner exception stack trace ---
I have checked my code over and over again and I am closing/disposing of all connections as soon as I’ve finished with them. I’m the only person accessing the application at the moment, but I keep getting this error. I’ve checked Process Info / Current Activity in SQL enterprise manager, and there are a normal number of connections open.
· How can I check or set the number of pooled connections I have available?
· Is there a way of increasing the pool size?
Any help would be much appreciated, as I'm currently in a state of panic!
Thanks,
John.
www.silveronion.com[^]
|
|
|
|
|
Following up on this problem, I think there was an issue with the server I was running this on. I moved the code to my local IIS server and it works fine.
I discovered that PerfMon lets me view the number of connection pools being used. .NET CLR Data / SQLClient:Current # pooled connections.
However – I did some testing by leaving connections open on purpose, the app falls over when it reaches 100 (as expected), but the pooled connection counter never seems to reset back to zero, even when I stop/start IIS. This may be related to the following:
BUG: SqlClient Performance Counters Do Not Reset
ID: Q314429
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q314429
I found this on a google search, but the KB Article no longer exists – So I don't know if Q314429 is still an issue
Is there a more reliable way to monitor the number of pooled connections?
Thanks,
John.
www.silveronion.com[^]
|
|
|
|
|
Hi,
I 'm Using ADOX from VC(I suppose ADO VB is same that ADO
VC) to create tables in Access 2000 and Access 97,
containing
several columns/fields with
the (Yes/No) or(datatime) data type. The format property
of these fields is blank and needs to be
set to (yes/no) or (format date).
I need to make this change by using code and not manually,
unfortunatly I can't see
any way of accessing the Format property of the field.
Is there somebody who know how can I chande Format
Property From ADO?
Or is there some SQL Statement that can do it? I.e.
Something like that:
"ALTER TABLE MyTable ALTER COLUMN DataTimeField DataTime
(here my format string)" --> ("Medium Date") or ("Long
Data")
or
"ALTER TABLE MyTable ALTER COLUMN YesOrNo YESNO(here my
format string)" --> ("Yes/No") or ("True/False")
Regards:
KalliMan.
|
|
|
|
|
I am a student considering purchasing Visual Studio.net 2003. However my main form of database connectivity is an ODBC connection to a mySql server. I know that the next version supports ODBC out of the box rather than having to download the ODBC.net driver from Microsoft. Here is my question? Does anyone know if in the new version Microsoft has updated the wizards for Database conectivity to use ODBC commands as well as the standard Microsoft Sql Server SQL commands? Somebody please help.
Aaron Flaugh
|
|
|
|
|
HotQuant, LLC, has posted a couple of articles to our site dealing with implementing ODBC in ASP .NET. Both articles contain lots of heavily documented source code. They are:
"Implementing ODBC in ASP .NET"
http://www.hotquant.com/proj/hqweb/odbc.aspx
"Encapsulating ODBC in ASP .NET"
http://www.hotquant.com/proj/hqweb/encap.aspx
You are welcome to link to these articles from your site. Hope they prove useful.
Regards,
Jason G. Williscroft
General Manager
HotQuant, LLC
|
|
|
|
|
I have a master detail form that has a text box for the search criteria for the master record when a button is pressed the textbox.text is used as a parameter to the sqldataadapter to populate the text box controls. The detail is also filled using the textbox.text as a parameter to its sqlDataadapter.
I am having to do a lot of maniputlation with the dataset and check that I have not yet bound the textboxs for the master list.
What is the best way to implement a search then edit master detail form.
|
|
|
|
|
This is probably a query that comes often... sorry if it is so...
Does anybody have any experience of using mySQL? Does it work? Is it reliable? Is there a proper ODBC or ADO encapsulation? Does it compare in terms of performance to SQL server? Any experience with multithreading and Visual C++ 6.0?
I do not actually need a monster of a database (something like a couple of hundreds of megabytes probably). The writing would be intensive, the reading much less.
Any caveat welcome... well any feedback would!
Thanks in advance!
BadJerry
|
|
|
|
|
I downloaded it to use with ADO and VC++. I found it sucked. I couldn't get it to work, or even figure out how to set it up. I was much happier to spend the money to use SQL Server or MS Access. Apparently, there is a reason MS dominates the market. Turns out free stuff is only free if your time is of no value. Just my limited experience with mySQL.
|
|
|
|
|
If you want something free, use MSDE, not MySQL.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
MySQL is a perfectly viable database. Version 4 even has a mechanism to embed a server within your application. I would agree that using it isn't for the faint of heart, however, just because it doesn't have an Access/Sql Server-like interface doesn't make it suck. What sucks is when people give up and say it sucks without giving it a fair shake doing what it does best--storing data. Once you get past the setup, it is just as easy to use as the others. As far as speed goes, MySql can keep up with the best of them. In my opinion, the only shortfall with MySql is the lack of stored procedures and transactions (though I think transactions have been added in version 4). If you go to the mysql.com website, you'll find programming APIs for different languages including C++. It is called MySql++. I've used it before and it works great. You can get MySQL++ from here: http://www.mysql.com/downloads/api-mysql++.html. Make sure you download the binary for VC++ 6.
Good luck.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Hi Matt,
I totally agree, MySQL is my fav DBMS and it only lacks Triggers and Stored Procedures. It's easy install (download and launch installer, then it runs as a NT service) and powerful.
However I wonder if you were able to handle a local database using MySQL++, local database : DB as a file (like MS Access .mdb files...).
JM. Molina
Web: http://goa.ifrance.com
|
|
|
|