|
Thanks for your reply
When I call The Stored Procedure directly from Sql Server it adds or
subtracts stock qty properly, but when i run it through vb6 code it adds or
subtracts qty twice. But its not in every execution of SP.
I m running my software for 3 to 4 years it never happened like this in SQL
Server 2000
|
|
|
|
|
What Tim is trying to suggest
1. Turn on SQL Profiler and start it running against your database
2. execute the stored procedure from the VB application
3. stop the profiler
4. in the results from the profiler you can see what was executed and the values that were passed to the stored procedure
http://technet.microsoft.com/en-us/library/ms181091(v=sql.105).aspx[^]
you need to be able to prove if it the database at fault or the stored procedure.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Thank you Simon for explaining me what Tim has suggested. Let me do what you both have said and let you know.
Thanks
|
|
|
|
|
jugnu_ad wrote: What could be the cause of this abnormal behavior? VB6.
Which existed waaaay before Sql Server 2008. Chances are that most of the code isn't type-safe but late-bound, and VB may be doing all kinds of magic on the background to make it work.
Did I mention that VB.NET is available for free?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Sounds like this may be the issue that finally gets him to update/rewrite his app into a current language. Now there will be a whole lot of pressure while he could have started this a decade ago (so speaks the guy still coding in Silverlight ).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
While VB 6 may have it issues, I have written and used in production many applications written in VB 6 pulling data from SQL Server without issue. If there is a problem, I suspect it is with the coding, not the underlying foundations.
|
|
|
|
|
Tim Carmichael wrote: While VB 6 may have it issues, I have written and used in production many applications written in VB 6 pulling data from SQL Server without issue. Ditto. I never claimed that VB6 has issues with SQL Server - merely that it existed before Sql 2008. VB6 does not know about Sql2k8, and I doubt that new released Sql versions are tested for backward compatibility for a discontinued product.
Tim Carmichael wrote: I suspect it is with the coding, not the underlying foundations. I agree with the first part of this statement, and explained how the underlying foundation can cause this.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
When you state that something isn't working, you need to show us what that 'something' is. I mean you haven't included your SP code here without which we will not be able to figure out what is wrong.
|
|
|
|
|
hi to all
i want to update a column from start point for example
i want to update from 10 .how can i do this
columns mycolumn
Row1 10
Row2 11
Row3 12
. .
. .
. .
|
|
|
|
|
I'm not sure if I understood you correctly, but you can use the UPDATE statement with a WHERE Clause to control which rows are updated.
UPDATE MyTable SET Column1 = 'Value1' WHERE mycolumn = 10
UPDATE MyTable SET Column1 = 'Value1' WHERE mycolumn > 10
UPDATE MyTable SET Column1 = 'Value1' WHERE mycolumn BETWEEN 10 AND 12
UPDATE MyTable SET Column1 = 'Value1' WHERE mycolumn IN (10, 12, 15, 30)
|
|
|
|
|
i want to update mycolumn with 10,11,12,.....
assume that my table have 100 row
then mycolumn with 10,11,...,110
thanks for answer
|
|
|
|
|
Still not clear. Update your question with sample data(like BEFORE and AFTER format) with clear explanation. Take your time.
before
A B
----
1 1
2 2 after
A B
----
2 2
3 3
|
|
|
|
|
befor
A B
----
1 NULL
2 NULL
3 NULL
4 NULL
after
A B
----
1 10
2 11
3 12
4 13
thanks
|
|
|
|
|
UPDATE TableName SET ColumnB = ColumnA + 9 I suggest you to spend more time on SQL basics, it'll save you lot of time.
|
|
|
|
|
ok but this is just a sample .
in column A i have a uniqueidentifier value .how can i write same tsql code that you write?
befor
A B
----
Guid Null
Guid Null
. .
. .
. .
after
A B
-----
Guid 10
Guid 11
, .
, .
, .
|
|
|
|
|
|
Hi,
Try this :
ColumnA is the primary key of table : tableName
UPDATE tableName SET columnB = 9 + t2.RowNum FROM tableName t1 INNER JOIN (
SELECT ROW_NUMBER() OVER (ORDER BY columnA) RowNum,columnA FROM tableName) t2 ON t1.columnA = t2.columnA
|
|
|
|
|
If ye be using SQL Server, then seek thee the ROW_NUMBER function.
If not, then at least tell us which database system you are using.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
ok
thanks for your time.
i solved it by code similar this
select *,ROW_NUMBER() OVER (ORDER BY [Guid] DESC) + 10 AS RN from tblTest
|
|
|
|
|
psst see the little arrow that appears next to the post - click that in appreciation of Piebalds help
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
Try this :
ColumnA is the primary key of table : tableName
UPDATE tableName SET columnB = 9 + t2.RowNum FROM tableName t1 INNER JOIN (
SELECT ROW_NUMBER() OVER (ORDER BY columnA) RowNum,columnA FROM tableName) t2 ON t1.columnA = t2.columnA
|
|
|
|
|
I'm having a temp table in which I'm inserting data. In temp table data is ok and I want to update another table with temp table data. I'm new to SQL My Query is:
update result_table set result_table.a = temp.a, result_table.b = temp.b from temp where temp.a= 1
I'm deleting the data in temp table and inserting data again in temp table and updating the result table.
How can I do this?
Please share your opinions.
Thanks!
|
|
|
|
|
You probaly want a JOIN in the FROM part -- JOIN the result_table to temp ON some key you haven't mentioned.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
I got these very weird scenario i encounter.
it happens when i try execute the sample provided in mysql doc about prepared statement, i created the table with columns correspond with the sample. mysql prepared statement
then when i execute it(BTW i used the c# sample), it populate the rows with 1000 entries.
after that i try to insert one entry with out the prepared statement (at this moment the ignore prepare property is set to true), then the executeNonQuery return 1, so it means it inserted the so i checked the database but the value i inserted is not in there, so i try it many time but still no luck.
so i decide to write the insert query directly to workbench, but i got thesame result the data was not there.
so i tried to delete the last row, then the weird things happen. it delete the the last row that has an the id of 1000(btw the id was autoincrement) it also insert 1 new data with the id of 1001, so try to delete to rows but after the two rows was deleted it also insert two more rows with the id of 1002 and 1003.
then after that i tried to insert new data but is still keep telling me that 1 row is inserted but i cant see that on the table so, i tried to delete rows still bu t it still doing the same.
BTW as u can see on the documentation the second column is a number, then when i delete the data it also insert now row with the incremented value of it.
so i decide to truncate the table and insert few row and then delete some of it, at this point it was working as expected, then i decide to execute the prepared statement(ignore prepare set to false) then after that it do the same weird things.
i dont know what on this, could somebody explain to me.
i will appreciate for any enlightenment will come.
thank you very much
|
|
|
|
|
Can you show us the query you are using to check the new rows, you allegedly inserted? You may also add your insert command...
Also read here to understand what ExecuteNonQuery exactly returns - http://waldev.blogspot.co.il/2008/01/return-value-of-executenonquery-in.html[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|