|
Never tried this before but, are you setting the AutoIncrement properties each time you add a row? If so, this may reset it back to -1.
You may want to look at Guid(vb/c#) / UNIQUEIDENTIFIER(SQL) for your primary keys. This will allow you to create primary keys locally and synchronize updates with the server. This I have done before and was able to sync insert/updates/deletes without any problems since foreign keys don't need to change.
|
|
|
|
|
Hello,
Thanks for the reply.
I think you may have shined some light on the problem.
I read in the xml files and create a new dataset and set the autoIncrement properties. So each time a user wants to add a new row it will do the same thing again. So I will be setting the autoIncrement properties each time.
The add form opens as a showDialog each time a user wants to add a new row. Is it possible to have a global dataset where it can be set only once?
However, there is still a problem I noticed if you look at the code snippet below, I set the autoIncrement once, then add 3 rows. But row 1 always gives a NULL for the incidentID PK.
example, why am I always getting a null for the first row?
Row 1 NULL
row 2 0
row 3 -1
etc.
<br />
Dim dr As DataRow<br />
'Set the auto increment columns<br />
dsIncidents.Tables(0).Columns("IncidentID").AutoIncrementSeed = 0<br />
dsIncidents.Tables(0).Columns("IncidentID").AutoIncrementStep = -1<br />
dsIncidents.Tables(0).Columns("IncidentID").AutoIncrement = True<br />
<br />
dr = dsIncidents.Tables(0).NewRow()<br />
dr("Company") = Me.cboCustomer.Text<br />
dr("Contact") = Me.cboContact.Text<br />
dr("PhoneNo") = Me.txtPhone.Text<br />
dr("Priority") = Me.cboPrority.Text<br />
dr("Subject") = Me.txtSubject.Text<br />
dr("AssignedTo") = Me.cboUsers.Text<br />
dsIncidents.Tables(0).Rows.Add(dr) 'Add the new row 1<br />
<br />
dr = dsIncidents.Tables(0).NewRow()<br />
dr("Company") = Me.cboCustomer.Text<br />
dr("Contact") = Me.cboContact.Text<br />
dr("PhoneNo") = Me.txtPhone.Text<br />
dr("Priority") = Me.cboPrority.Text<br />
dr("Subject") = Me.txtSubject.Text<br />
dr("AssignedTo") = Me.cboUsers.Text<br />
dsIncidents.Tables(0).Rows.Add(dr) 'Add the new row 2<br />
<br />
dr = dsIncidents.Tables(0).NewRow()<br />
dr("Company") = Me.cboCustomer.Text<br />
dr("Contact") = Me.cboContact.Text<br />
dr("PhoneNo") = Me.txtPhone.Text<br />
dr("Priority") = Me.cboPrority.Text<br />
dr("Subject") = Me.txtSubject.Text<br />
dr("AssignedTo") = Me.cboUsers.Text<br />
dsIncidents.Tables(0).Rows.Add(dr) 'Add the new row 3<br />
Many thanks for any extra help with this problem.
Steve
|
|
|
|
|
Check the AllowDBNull value on the column. It should be set to FALSE . Just guessing....
|
|
|
|
|
Hello,
Thanks for your continued support.
I have set the allowDBNull:
<br />
dsIncidents.Tables(0).Columns("IncidentID").AllowDBNull = False<br />
I get an exception error when I added the new row: "Column 'IncidentID' does not allow nulls"
When I take out the above line and run the program. On careful inspection the incident column is 'system.DBNull', when I check the other rows the incident column is what I would expect it to be, 0, -1, -2, etc.
Any other ideas would be most helpful,
Many thanks for your help,
Steve
|
|
|
|
|
Hello,
Problem solved, not sure what I did but seems to be working now. I guess that is programming.
Thanks for the advice and help,
Steve
|
|
|
|
|
Hi Dear All,
Can anybody help me? I am new to the web services in .net. So requesting for the free downloadable e-book for the webservices. Or whitepapres or any material that demonstrates the all the stuffs of the Web Services, from strach..
Thanks!!!
Warm Regards
Sushilkumar Jadhav
Cell +91 98509 87349
|
|
|
|
|
You seem to be confused. This forum is for SQL/ADO/ADO.NET. It seems to be missing the bit that says web services.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All
Dont get me wrong i buy books,but hey my problem is out of scope, but i can solve it, and have already solved it many times. i need a site where i can download E-books for free in the Following Subject.
ADO.NET 1.1 or 2.0
VB.net 2003 or 2005
Thanks
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
Try here[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi
i did not see the Thread before. anyway thank you very much
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sudden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
|
|
|
|
|
Hello Everyone,
What is the difference between join and nested queries.......
and which is executed fast
-----------------------------------
|
|
|
|
|
The Knowledge wrote: What is the difference between join and nested queries.......
and which is executed fast
A join, ummm... joins two tables together.
SELECT * FROM A INNER JOIN B ON A.PK = B.FK
A nested query (aka sub-queries) runs one query inside another.
SELECT * FROM (SELECT * FROM A) -- Okay this is a bit of a useless example
I wouldn't say that either is faster than the other. Although, from what I can see, it is easier to make a mess of nested queries which will affect performance negatively. Typically a nested query will be used with a join anyway.
SELECT * FROM A<br />
INNER JOIN (SELECT * FROM B) AS nestedB ON A.PK = nestedB.FK
Okay, that's another pointless example, but it does demonstrate the basic syntax. Often, the sub-query will be used with some sort of group by clause.
|
|
|
|
|
Hi,
it is very hard to find a general answer on your question and it really depends on the situation and database schema behind (indexes at most). If you are trying to join two tables with, let's say more than 30 millions of records it will take forever, but if you have a good filtering on the second one and than using that in subquery it will fly. On other way, in a lot of situations, for example, SQL Server will treat your subquery as separate one and perform a separate optimization plan which costs time. There are two different types of subqueries, self-contained (run independently of the outer query) and correlated ones (have references to outer query columns) and they also behave differently. The same is for joins. SQL Server now has a couple of join algorithms used by query optimizer (loop join, merge join and hash join) in different situation.
To get a real answer in a particular situation, is possible by just examine execution plan for both queries and than decide which one to use.
In addition to this, I would always consider using CTE (Common table Expressions) (at least on SQL Server 2005) as one of the most effective ways of subquerying.
Hope this helps a little bit.
Best regards,
DLM@bypsoft.com
|
|
|
|
|
can we use arrays in a sored procedure
if not, is there any alternative to store the values somewhere dynamically from where we will be able to use the values.
|
|
|
|
|
nicetohaveyou wrote: store the values somewhere
Will a temp table suffice ? (With respect to SqlServer)
|
|
|
|
|
can we use a temp table dynamically inside a T-SQL statement
|
|
|
|
|
You can, and you can also use a table variable. This is, effectively, an in memory temporary table.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
I am using Sql Reporting Services 2000 viewer in my asp.net1.1 page.
The report which i developed is showing results perfectly.I opened my application in another browser and submited some new data thru some interface .When i generate the report again the data is not showing in the report viewer. But when i logout and login into my application and generated report and the data is getting displayed. Can anyone tell me the cause for this problem.
Thanks in Advance
Phanindra...
|
|
|
|
|
Check the properties of the report it sounds like you might be caching the data or using report snapshots?
|
|
|
|
|
Hi all,
I'm making use of C++ to connect to a ODBC Oracle database, but when I do, I receive the following error:
(I'm making use of Microsoft's ODBC driver for Oracle)
[MOD]
I have have made an entry within my tnsnames.ora
my_database =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = my_host)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = my_database)
)
)
I have tried to ping the DSN and got the following:
C:\>tnsping MSORA
C:\>tnsping MSORA
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 14-SEP-2
007 08:28:33
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
H:\ORACLE\app\oracle\product\10.2.0\server\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = pcname.local)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = X
E)))
OK (20 msec)
[MOD]
[Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: TNS:could not resolve the connect identifier specified
Many Thanks in advance
Regards,
-- modified at 2:15 Friday 14th September, 2007
-- modified at 2:20 Friday 14th September, 2007
-- modified at 2:29 Friday 14th September, 2007
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
|
i want to access a database stored in sql 2005 stored in a different machine through DSN from a different machine in a network.
How do i do that?
|
|
|
|
|
|
Hi Everyone.
I'm finding it hard to get information of verifying variables passed into a stored procedure. Specifically if the value is NULL then I want to abort the procedure and let VB.NET know the insert failed without issuing an exception.
I found some information that gave me the following IF statement but the layout is not like VB so I'm not sure where to go from here...
IF (@RateLevel1 IS NOT NULL) OR (@RateLevel2 IS NOT NULL)
NOTE: I borrowed the following code from a tutorial video so if you find any issues please let me know.
ALTER PROCEDURE dbo.sptblBillingRatesInsert
(
@Description nvarchar(150),
@RateLevel1 money,
@RateLevel2 money,
@RateLevel3 money,
@RateLevel4 money,
@RateLevel5 money,
@BillingLevelID int OUTPUT,
@ModifiedStamp timestamp OUTPUT
)
AS
SET NOCOUNT ON;
-- Inserts a row in Billing Rates
INSERT INTO tblBillingRates
(Description, RateLevel1, RateLevel2, RateLevel3, RateLevel4, RateLevel5)
VALUES
(@Description, @RateLevel1, @RateLevel2, @RateLevel3, @RateLevel4, @RateLevel5);
-- Checks if the last statement produced an error
IF @@ROWCOUNT>0 AND @@ERROR=0
SELECT @BillingLevelID = BillingLevelID, @ModifiedStamp = ModifiedStamp
FROM tblBillingRates
WHERE (BillingLevelID = SCOPE_IDENTITY());
|
|
|
|
|
hi,like this?
IF (@RateLevel1 IS NOT NULL) and (@RateLevel2 IS NOT NULL) ...
begin
raiserror 'parameters null value!'
return 1 --fail
end
else
begin
insert into ...
return 0 --success
end
|
|
|
|