I have a very simple Insert Stored Procedure. When I run it from the Server Explorer, it inserts the records just fine. However, when I try to call it from my form, it does not update the table. The weird thing is that it does return one row effected and if I try it again, I am told my primary key is not unique (meaning the first record is in there somewhere). When I exit my app, my table is just the same as it was before the inserts. Do I need to "save" or "update" the table before closing a connection? Thanks -
CREATE PROCEDURE dbo.InsertNew
-
(
-
@A nchar(10),
-
@B nvarchar(50),
-
@C nvarchar(50),
-
@D nvarchar(50),
-
@E nvarchar(50),
-
@F nvarchar(50),
-
@G nvarchar(50),
-
@H nvarchar(50)
-
)
-
AS
-
INSERT INTO Users
-
(
-
A,
-
B,
-
C,
-
D,
-
E,
-
F,
-
G,
-
H
-
)
-
VALUES
-
(
-
@A,
-
@B,
-
@C,
-
@D,
-
@E,
-
@F,
-
@G,
-
@H
-
)
-
RETURN
-
-
-
-
-
-
Dim connection As SqlConnection
-
connection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")
-
connection.Open()
-
Dim command As SqlCommand = New SqlCommand("InsertNew", connection)
-
command.CommandType = CommandType.StoredProcedure
-
command.Parameters.AddWithValue("@A", "99")
-
command.Parameters.AddWithValue("@B", "test")
-
command.Parameters.AddWithValue("@C", "test")
-
command.Parameters.AddWithValue("@D", "test")
-
command.Parameters.AddWithValue("@E", "test")
-
command.Parameters.AddWithValue("@F", "test")
-
command.Parameters.AddWithValue("@G", "test")
-
command.Parameters.AddWithValue("@H", "test")
-
Dim rows
-
rows = command.ExecuteNonQuery
-
connection.Close()
-
-
If (rows = 1) Then
-
MessageBox.Show("Create new user SUCCESS!")
-
Else
-
MessageBox.Show("Create new user FAILED!")
-
End If
-
-
2 983
This may have to do with some database settings, dealing with Transactions and Auto-commit settings.
I don't know much beyond that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dinesh prasad |
last post by:
I'm trying to use a servlet to process a form, then send that data to
an SQL server stored procedure. I'm using the WebLogic 8 App. server.
I am able to retrieve database information, so I know my...
|
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft...
|
by: Rhino |
last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a
Throwable back to the calling program as an OUT parameter?
If yes, what datatype should I use when registering the...
|
by: Dino L. |
last post by:
How can I run stored procedure (MSSQL) ?
|
by: jed |
last post by:
I have created this example in sqlexpress
ALTER PROCEDURE .
@annualtax FLOAT
AS
BEGIN
SELECT begin1,end1,deductedamount,pecentageextra
FROM tax
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |