Monday, March 12, 2012
Reverse enginnering in VISIO 2002 (problem with sp_primarykey)
The database uses primary key created with sp_primarykey an foreign keys with sp_foreingnkey
In VISIO - Database - Options - Drivers I had set the DDL script generationas follows:
Preffered version - 6.0
Generate primary key using - sp_primarykey
Generate foregin key using - sp_foreignkey
The process had passed without errors, but the relations didn't showed.
I tried option "Show related tables" but nothing didn't happend.
thanks.That could possibily be because of the loss of dependensies. The happens when you drop and recreate few objects in the database, which does ot re-establish the dependensies.
Try recompiling the objects or establishing the foreign keys again.
Thanks.
Friday, March 9, 2012
Reuse deleted primary key id
Hello,
Can I reuse the deleted primary key id? I'm using SQLServer2005.
cheers,
imperialx
Yeah, that is no problem.
|||Hi jamesqua,
I should have asked like this, "How can I reuse the deletedprimary key id?"
cheers,
imperialx
|||
Can i no u r exact requirement. deleted primary key id means ?
if its a value no problem. U can reuse it.
I think There is no way to store the deleted value(ofcourse u can place into a temp table or another. Incase of procedures its different).Plz check out
Exact wt i need is u r requirement . How u want to deal it.Explanation needed (Thank u)
Thank u
Baba
Please remember to click "Mark as Answer" on this post if it helped you.
|||Hi srijaya,
srijaya_ramaraju@.yahoo.com:
...Exact wt i need is u r requirement . How u want to deal it.Explanation needed (Thank u)...
The primary key is incremented by 1 in every addition of data by default, letsay the primary key value is 56, if this row is deleted then I couldn't use thevalue 56 because the next primary key value will be 57 when adding a new data.
My tablewill now look like so, as you can see the id field values aren't sequentially accumulatedby 1.
id |username
1 | Tedd
2 | Scott
3 | Bing
57 | Mich
58 | Jake
76 | Jenn
77 | Lea
Can SQLServer2005 reuse the deleted primary key for me to have a sequencial value for my id fields?
Hope I explain my problem plainly.
cheers,
imperialx
U r primary key column is defined with Identity property. Thats the reason u r Primary column id will be incremented by 1(or as per the seed). Once we removed that entry. I think its not possible(99.99%). So choice is u rs. U want to go with identity column u can. or manually u have to write the code.
Plz correct me if i m wrong.
Thank u
Baba
Please remember to click "Mark as Answer" on this post if it helped you.
|||If your primary key is an identity column you can't reuse it. You have to rely on the number generated by sql server and can't put your own values in there. If this behavior does not meet your requirements I would suggest going with a non-identity public key.
Wednesday, March 7, 2012
Returning values from unique index
My primary key is "key".
Then i create a unique index for fields "field1" and "field2".
This works, but i want that sql server retrieve me the values thar are being
duplicated.
I'm using sql server 7.0.
Ex: Table1 as the following values:
-0;0;0;0;
-1;1;1;1;
-2;2;2;2;
I have a second table with the values:
-3;3;3;3;
-4;1;1;1;
-5;0;0;0;
-6;0;0;0;
if i do a insert (insert into table1 select * from table2), it gives me an
error but i want that sql tell me that the error was because of values
4;1;1;1-5;0;0;0-6;0;0;0.
I hope this helps.
Can anyone help me?What was the error you got?
Madhivanan|||SQL Server won't identify the duplicated rows automatically for you.
You'll have to do a separate query:
SELECT T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
You could also insert only the unique rows as follows:
INSERT INTO Table1 (col1, col2, cole, col4)
SELECT T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
LEFT JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
WHERE T1.col1 IS NULL
David Portas
SQL Server MVP
--|||Hi David,
INSERT INTO Table1 (col1, col2, cole, col4)
SELECT T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
LEFT JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
WHERE T1.col1 IS NULL <<
I think that a DISTINCT should be added to the SELECT list.
Cheers,
--
BG, SQL Server MVP
www.SolidQualityLearning.com
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1111143246.610107.236070@.g14g2000cwa.googlegroups.com...
> SQL Server won't identify the duplicated rows automatically for you.
> You'll have to do a separate query:
> SELECT T2.col1, T2.col2, T2.col3, T2.col4
> FROM Table2 AS T2
> JOIN Table1 AS T1
> ON T1.col1 = T2.col1
> AND T1.col2 = T2.col2
> You could also insert only the unique rows as follows:
> INSERT INTO Table1 (col1, col2, cole, col4)
> SELECT T2.col1, T2.col2, T2.col3, T2.col4
> FROM Table2 AS T2
> LEFT JOIN Table1 AS T1
> ON T1.col1 = T2.col1
> AND T1.col2 = T2.col2
> WHERE T1.col1 IS NULL
> --
> David Portas
> SQL Server MVP
> --
>|||On Fri, 18 Mar 2005 10:26:40 -0000, Joaquim Meireles wrote:
>I have a table1(key, field1, field2, field3...).
>My primary key is "key".
>Then i create a unique index for fields "field1" and "field2".
>This works, but i want that sql server retrieve me the values thar are bein
g
>duplicated.
>I'm using sql server 7.0.
>Ex: Table1 as the following values:
> -0;0;0;0;
> -1;1;1;1;
> -2;2;2;2;
>I have a second table with the values:
> -3;3;3;3;
> -4;1;1;1;
> -5;0;0;0;
> -6;0;0;0;
>if i do a insert (insert into table1 select * from table2), it gives me an
>error but i want that sql tell me that the error was because of values
>4;1;1;1-5;0;0;0-6;0;0;0.
Hi Joaquim,
A constraint won't do that - a constraint simply constrains, that's all.
As David says, you need to use a query. However, the query he posted
won't return all duplicate rows. Try this one instead:
SELECT T2.key, T2.col1, T2.col2, T2.col3, T2.col4
FROM Table2 AS T2
LEFT JOIN Table1 AS T1
ON T1.col1 = T2.col1
AND T1.col2 = T2.col2
WHERE T1.key IS NOT NULL
OR EXISTS (SELECT *
FROM Table2 AS T2b
WHERE T2b.col1 = T2.col1
AND T2b.col2 = T2.col2
AND T2b.key <> T2.key)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
returning the primary key of the last rows updated
UPDATE Members SET LastLog = @.time WHERE UserName=@.user AND Password=@.pass;
Thanks in advance,
Is the primary key an IDENTITY value? If so then you could do this:
UPDATE Members SET LastLog = @.time WHERE UserName=@.user AND Password=@.pass;SELECT @.myPrimaryKey = SCOPE_IDENTITY()
|||I am trying to kill 2 birds with uno piedro
My first quess was to do:
PDATE Members SET LastLog = @.time WHERE UserName=@.user AND Password=@.pass;SELECT SCOPE_IDENTITY()
But this keeps returning (NULL) - even though the row has been updated.
Thanks in advance
|||Can you post more of your code?
|||
Actually - this is what I was putting in my query analyzer-|||Oh gosh, I just realized that you are doing an UPDATE, not an INSERT! I don't know where my head was; I'm sorry.
UPDATE Members SET LastLog = @.time WHERE UserName=@.user AND Password=@.pass;
its ok -
I will just work with using this :UPDATE Members SET LastLog = @.time WHERE UserName=@.user AND Password=@.pass; SELECT MemberID WHERE UserName=@.user AND Password=@.pass;I will just dig around some more.
In that case I would SELECT the MemeberID to be UPDATEd first into avariable, then perform the UPDATE with the WHERE condition being theMemberID you determined.
|||How about using an output parameter and assigning it SCOPE_IDENTITY or @.@.IDENTITY?
I'm not sure if @.@.IDENTITY only gets set to the ID of the latest INSERT or also UPDATE. It would be easy to try of course.
Returning the Primary Key
if you are using a stored procedure to insert then
Function()
Delcare con,
Delcare command,adapters etc....
'declare a param
Dim parameter1 As New SqlParameter("@.ID", SqlDbType.Int)
parameter1.Direction = ParameterDirection.Output
'after the executescalar
Dim iID As Integer = yourcommand.Parameters("@.ID").Value.ToString()
Return iID
End Function
Hope this helps?
m_7e7|||Multiple ways to get Identity value from SQL:
System variable @.@.Identity, this is database scope
Function SCOPE_IDENTITY(), Or IDENT_CURRENT('Table name')|||I might have to do it the srored procedure way, however at the moment i'm just using a function that executes the sql variable when it's called e.g
Dim queryString As String = "INSERT INTO [tblKnowledgeBase] ([knowledgeTitle], [knowledgeType], [knowledgeCust"& _
"omerView], [knowledgeProjectID], [knowledgeDesc], [knowledgeAttachName], [knowle"& _
"dgeAttachType], [knowledgeAttachSize], [knowledgeAdditionUserID], [knowledgeAddi"& _
"tionDate], [KnowledgeApproved]) VALUES (@.knowledgeTitle, @.knowledgeType, @.knowle"& _
"dgeCustomerView, @.knowledgeProjectID, @.knowledgeDesc, @.knowledgeAttachName, @.kno"& _
"wledgeAttachType, @.knowledgeAttachSize, @.knowledgeAdditionUserID, @.knowledgeAddi"& _
"tionDate, @.KnowledgeApproved)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnectionDim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End TryReturn rowsAffected
Is there a way I can retrieve it with this method of insertion, If I use stored procedures I will have compatibility problems when creating a microsoft Access/mySQL version.|||Is your ID(Primary Key) a AutoNumber ??|||My advice would be to bite the bullet and use a stored proc.|||Try this query instead.............
Dim queryString As String = "INSERT INTO [tblKnowledgeBase] ([knowledgeTitle], [knowledgeType], [knowledgeCust"& _
"omerView], [knowledgeProjectID], [knowledgeDesc], [knowledgeAttachName], [knowle"& _
"dgeAttachType], [knowledgeAttachSize], [knowledgeAdditionUserID], [knowledgeAddi"& _
"tionDate], [KnowledgeApproved]) VALUES (@.knowledgeTitle, @.knowledgeType, @.knowle"& _
"dgeCustomerView, @.knowledgeProjectID, @.knowledgeDesc, @.knowledgeAttachName, @.kno"& _
"wledgeAttachType, @.knowledgeAttachSize, @.knowledgeAdditionUserID, @.knowledgeAddi"& _
"tionDate, @.KnowledgeApproved)";"SELECT @.@.IDENTITY AS Ident";
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.Executescalar
Finally
dbConnection.Close
End Try
Return rowsAffected
*********Note*************
Use an executescalar instead of execnonquery and try.....|||Yeah it is an utonumber|||hey you got it???
Saturday, February 25, 2012
returning random records
The table has a numeric ID column that is a primary key (identity
property). I would like to return a set of 1000 records where the only
criteria is a random ID number.
I can come up with a cursor solution that does what I need but is there a
set-based solution to the problem?
What is the most efficient way to return say 1000 random records from a
table?Try:
select top 1000
*
from
MyTable
order by
newid()
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Dave" <Dave@.discussions.microsoft.com> wrote in message
news:25157515-DC71-4A34-B4C5-EE30FBD1E234@.microsoft.com...
>I need to select a list of random records from a table.
> The table has a numeric ID column that is a primary key (identity
> property). I would like to return a set of 1000 records where the only
> criteria is a random ID number.
> I can come up with a cursor solution that does what I need but is there a
> set-based solution to the problem?
> What is the most efficient way to return say 1000 random records from a
> table?
>
>|||Dave
You need to perfrom
SELECT TOP 1000 *
FROM table
ORDER BY NEWID()
as per the example below:
CREATE TABLE foo
(
i INT
)
SET NOCOUNT OFF
DECLARE @.maxVal BIGINT
DECLARE @.i BIGINT
SET @.maxVal = 10000
SET @.i = 1
BEGIN TRAN
INSERT INTO foo VALUES(1)
WHILE @.i * 2 <= @.maxVal
BEGIN
INSERT INTO foo
SELECT i + @.i FROM foo
SET @.i = @.i * 2
END
INSERT INTO foo
SELECT i + @.i FROM foo
WHERE i + @.i <= @.maxVal
COMMIT TRAN
SELECT TOP 1000 *
FROM foo
ORDER BY NEWID()
- Peter Ward
WARDY IT Solutions
"Dave" wrote:
> I need to select a list of random records from a table.
> The table has a numeric ID column that is a primary key (identity
> property). I would like to return a set of 1000 records where the only
> criteria is a random ID number.
> I can come up with a cursor solution that does what I need but is there a
> set-based solution to the problem?
> What is the most efficient way to return say 1000 random records from a
> table?
>
>|||Hey that will not give randon records but same kind of records everytime as
top uses the same logic( it may be same order)
so you have some thing called RAND function. see books online for that. You
have to do little bit of work to achive the results using rand function. see
books online for that.
Regards
R.D
--Knowledge gets doubled when shared
"P. Ward" wrote:
> Dave
> You need to perfrom
> SELECT TOP 1000 *
> FROM table
> ORDER BY NEWID()
> as per the example below:
>
> CREATE TABLE foo
> (
> i INT
> )
>
> SET NOCOUNT OFF
> DECLARE @.maxVal BIGINT
> DECLARE @.i BIGINT
> SET @.maxVal = 10000
> SET @.i = 1
> BEGIN TRAN
> INSERT INTO foo VALUES(1)
> WHILE @.i * 2 <= @.maxVal
> BEGIN
> INSERT INTO foo
> SELECT i + @.i FROM foo
> SET @.i = @.i * 2
> END
> INSERT INTO foo
> SELECT i + @.i FROM foo
> WHERE i + @.i <= @.maxVal
> COMMIT TRAN
>
> SELECT TOP 1000 *
> FROM foo
> ORDER BY NEWID()
>
> - Peter Ward
> WARDY IT Solutions
>
> "Dave" wrote:
>|||Dave
This should solve your problem: Read this article
http://msdn.microsoft.com/library/d...r />
p04c1.asp
--
Regards
R.D
--Knowledge gets doubled when shared
"Dave" wrote:
> I need to select a list of random records from a table.
> The table has a numeric ID column that is a primary key (identity
> property). I would like to return a set of 1000 records where the only
> criteria is a random ID number.
> I can come up with a cursor solution that does what I need but is there a
> set-based solution to the problem?
> What is the most efficient way to return say 1000 random records from a
> table?
>
>|||On Mon, 7 Nov 2005 21:19:15 -0800, R.D wrote:
>Hey that will not give randon records but same kind of records everytime as
>top uses the same logic( it may be same order)
Hi R.D.,
You're incorrect. This WILL give random rows.
The TOP is executed in conjunction with the ORDER BY. So before applying
the TOP, SQL Server will first order all rows. NEWID() is called for
each row; this results in a semi-random (*) value. The rows are then
ordered by this semi-random value, resulting in a semi-random order.
Then, the TOP 1000 of those semi-randoomly ordered rows are returned.
Try executing the following in Nirthwind:
SELECT TOP 5 * FROM Customers
ORDER BY NEWID()
SELECT TOP 5 * FROM Customers
ORDER BY NEWID()
SELECT TOP 5 * FROM Customers
ORDER BY NEWID()
(*) The generator for NEWID's is not designed to be a good random number
generator, but it's close enoguh for most practical purposes. I wouldn't
use it for serious gambling-strategy analysis or for the 15 million
dollar draw, but for getting random samples out of a table, it's
certainly good enough.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||The first problem is that there are two kinds of random selection from
a set:
1) With replacement = you can get multiple copies of the same value.
This is shooting dice.
This one is easy if you have a random function in your SQL product.
Most of the pseudo-random generators return a floating point fraction
value between 0.00 and 0.9999... at whatever precision your SQL engine
has. The choice of a seed to start the generator can be the system
clock or some other constantly changing value.
SELECT S1.key_col
FROM SomeTable AS S1, SomeTable AS S2
WHERE S1.key_col <= S2.key_col
GROUP BY S1.key_col
HAVING COUNT(S2.key_col)
= (SELECT COUNT(*)
FROM SomeTable AS S3) * RANDOM(seed) + 1.0;
Or you can add a column for this in SQL Server (but not Oracle).
CREATE TABLE RandNbrs2
(seq_nbr INTEGER PRIMARY KEY,
randomizer FLOAT -- warning !! not standard SQL
DEFAULT (
(CASE (CAST(RAND() + 0.5 AS INTEGER) * -1)
WHEN 0.0 THEN 1.0 ELSE -1.0 END)
* (CAST(RAND() * 100000 AS INTEGER) % 10000)
* RAND())
NOT NULL);
INSERT INTO RandNbrs2 VALUES (1, DEFAULT);
INSERT INTO RandNbrs2 VALUES (2, DEFAULT);
INSERT INTO RandNbrs2 VALUES (3, DEFAULT);
INSERT INTO RandNbrs2 VALUES (4, DEFAULT);
INSERT INTO RandNbrs2 VALUES (5, DEFAULT);
INSERT INTO RandNbrs2 VALUES (6, DEFAULT);
INSERT INTO RandNbrs2 VALUES (7, DEFAULT);
INSERT INTO RandNbrs2 VALUES (8, DEFAULT);
INSERT INTO RandNbrs2 VALUES (9, DEFAULT);
INSERT INTO RandNbrs2 VALUES (10, DEFAULT);
2) Without replacement = you can each value only once. This is dealing
playing cards.
This is trickier. I would start with a table that has the keys and a
sequentially numbered column in it:
CREATE TABLE CardDeck
(keycol <datatype> NOT NULL PRIMARY KEY,
seq INTEGER NOT NULL);
INSERT INTO CardDeck (keycol, seq)
SELECT S1.keycol, COUNT(S2.keycol)
FROM SomeTable AS S1, Sometable AS S2
WHERE S1.key_col <= S2.key_col
GROUP BY S1.key_col;
Now shuffle the deck by determing a random swap pair for all the rows.
Somethign like this in SQL/PSM
BEGIN
DECLARE i INTEGER, j INTEGER;
SET i = (SELECT COUNT(*) FROM CardDeck);
WHILE i < 0
LOOP
SET j = (SELECT COUNT(*) FROM CardDeck) * RANDOM(seed) + 1.0;
UPDATE CardDeck
SET seq = CASE WHEN seq = i THEN j
WHEN seq = j THEN i
ELSE seq END;
WHERE seq IN (i, j);
SET i = i - 1;
LOOP END;
END;
You don't really need j, but it makes the code easier to read.
Biography:
Marsaglia, G and Zaman, A. 1990. Toward a Univesal Random Number
Generator.
Statistics & Probability Letters 8 (1990) 35-39.
Marsaglia, G, B. Narasimhan, and A. Zaman. 1990. A Random Number
Generator for
PC's. Computer Physics Communications 60 (1990) 345-349.
Leva, Joseph L. 1992. A Fast Normal Random Number Generator. ACM
Transactions
on Mathematical Software. Dec 01 1992 v 18 n 4. p 449
Leva, Joseph L. 1992. Algorithm 712: A Normal Random Number Generator.
ACM
Transactions on Mathematical Software. Dec 01 1992 v 18 n 4. p 454
Bays, Carter and W.E. Sharp. 1992. Improved Random Numbers for Your
Personal
Computer or Workstation. Geobyte. Apr 01 1992 v7 n2. p 25
Hulquist, Paul F. 1991. A Good Random Number Generator for
Microcomputers.
Simulation. Oct 01 1991 v57 n 4. p 258
Komo, John J. 1991. Decimal Pseudo-random Number Generator. Simulation.
Oct 01
1991 v57 n4. p 228
Chambers, W.G. and Z.D. Dai. 1991. Simple but Effective Modification to
a
Multiplicative Congruential Random-number Generator. IEEE Proceedings.
Computers and Digital Technology. May 01 1991 v 138 n3. p 121
Maier, W.L. 1991.. A Fast Pseudo Random Number Generator. Dr. Dobb's
Journal.
May 01 1991 v17 n 5. p 152
Sezgin, Fatin. 1990. On a Fast and Portable Uniform Quasi-random Number
Generator. Simulation Digest. Wint 1990 v 21 n 2. p 30
Macomber, James H. and Charles S. White. 1990. An n-Dimensional Uniform
Random
Number Generator Suitible for IBM-Compatible Microcomputers.
Interfaces. May 01
1990 v 20 n 3. p 49
Carta, David G. 1990. Two Fast Implementations of the "Minimal
Standard"
Random Number Generator. Communications of the ACM. Jan 01 1990 v 33 n
1. p
87
Elkins, T.A. 1989. A Highly Random-number Generator. Computer
Language. Dec
01 1989 v 6 n 12 p 59
Kao, Chiang. A Random Number Generator for Microcomputers. OR: The
Journal of
the Operational Research Society. Jul 01 1989 v 40 n 7. p 687
Chassing, P. 1989. An Optimal Random Number Generator Zp. Statistics &
Probability Letters. Feb 01 1989 v 7 n 4. p 307
Also, you can contact Kenneth G. Hamilton 72727,177 who has done some
work
with RNG's. He has implemented one (at least one) of the best.
"A Digital Dissolve for Bit-Mapped Graphics Screens" by Mike Morton in
Dr.
Dobb's Journal, November 1986, page 48.
CMOS Cookbook by Don Lancaster; Sams 1977, page 318.
Art of Computer Programming, Volume 2: Seminumeral Algorithms, 2nd
edition by
Donald Knuth; Addison-Wesley 1981; page 29.
Numerical Recipes in Pascal: The Art of Scientific Computing by Press
et al.;
Cambridge 1989; page 233.
Returning primary key from insert sp?
Hi,
I've got a stored procedure that's inserting data into a sql database fine. The only problem is that I'm not sure how to read back the value of the auto increment field that was just generated by the insert (e.g the id field).
Any help appreciated.
After any INSERT statement, you can do:
SELECT SCOPE_IDENTITY()
or
SELECT @.@.IDENTITY
(use the top one).
Mark this as the answer, because it is :)
Tuesday, February 21, 2012
returning key value with Insert
Hello,
Use SCOPE_IDENTITY() or @.@.IDENTITY
e.g
SELECT @.@.IDENTITY
HTH
regards
|||
Thanks. Sorry, I still don't understand (fairly new to ASP.net). Code is below. After my 'ExecuteNonQuery' command is performed, I want to know the value of the IdentityColumn (not referenced in code below) that was automatically added. ?? Thanks for your patience.
******************************************************************************************
PublicSharedFunction AddReport(ByVal passRepLayoutAs Report)AsBoolean
Dim dbConnectionAs SqlConnection = QuoteDBConnection()
Dim sAddAsString = "Insert Into Report(QuoteNumber, Driver, ReportType, ReportID, OrderDate, DataFile) " _
& "Values(@.QuoteNumber, @.Driver, @.ReportType, @.ReportID, @.OrderDate, @.DataFile)"
Dim dbCmdAsNew SqlCommand(sAdd, dbConnection)
With passRepLayout
dbCmd.Parameters.Add("@.QuoteNumber", .QuoteNumber)
dbCmd.Parameters.Add("@.Driver", .Driver)
dbCmd.Parameters.Add("@.ReportType", .ReportType)
dbCmd.Parameters.Add("@.ReportID", .ReportID)
dbCmd.Parameters.Add("@.OrderDate", .OrderDate)
dbCmd.Parameters.Add("@.DataFile", .DataFile)
EndWith
dbConnection.Open()
Try
dbCmd.ExecuteNonQuery()
IdentityColumnValue = ?
AddReport =True
Catch exAs Exception
AddReport =False
EndTry
dbConnection.Close()
EndFunction
|||Dim sAddAsString="Insert Into Report(QuoteNumber, Driver, ReportType, ReportID, OrderDate, DataFile) " _
&"Values(@.QuoteNumber, @.Driver, @.ReportType, @.ReportID, @.OrderDate, @.DataFile) SELECT SCOPE_IDENTITY()"
and use ExecuteScalar instead of ExecuteNonQuery.
dim resultidasinteger
resultid= dbCmd.ExecuteScalar()
|||Thank- you very much.