Francesco
New member
- Joined
- Aug 24, 2006
- Messages
- 4
- Programming Experience
- 10+
Getting my feet wet with .NET, and I bump in to this stupid problem that I trust you can help me with.
I have a (local) database, with some stored procedures for inserting, deleting, etc.
Stored procedures work just fine when I execute them by hand.
Created a tableadapter with these stored procedures in it. Now when I use that to insert a new record, something seeeeeems to happen. I get (good)results back from the insert and update functions, It is skipping existing records in another sub (meaning that it does not insert records twice). But if I check my database at the end of the program, no records have been added.
It is just as if no commit has taken place
Now I added commits in my SP. Based on what I read at MSDN, I added an update after my insert, but still....nada.
This CANNOT be so hard! ......Can it?
I tried the blasted thing also with a sqlCommand, but with the same results (or lack of).
I have a (local) database, with some stored procedures for inserting, deleting, etc.
Stored procedures work just fine when I execute them by hand.
Created a tableadapter with these stored procedures in it. Now when I use that to insert a new record, something seeeeeems to happen. I get (good)results back from the insert and update functions, It is skipping existing records in another sub (meaning that it does not insert records twice). But if I check my database at the end of the program, no records have been added.
It is just as if no commit has taken place
Now I added commits in my SP. Based on what I read at MSDN, I added an update after my insert, but still....nada.
This CANNOT be so hard! ......Can it?
VB.NET:
[SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] LoadName([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] name [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] res [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] tableadapter [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CatalogDataSetTableAdapters.ArtistTableAdapter[/SIZE]
[SIZE=2]res = tableadapter.Insert(name, "")[/SIZE]
[SIZE=2]res = tableadapter.Update(name)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
VB.NET:
[SIZE=2][COLOR=#0000ff]ALTER PROCEDURE [/COLOR][/SIZE][SIZE=2]dbo.spInsertName(@Name [/SIZE][SIZE=2][COLOR=#0000ff]nvarchar[/COLOR][/SIZE][SIZE=2](50),@Notation [/SIZE][SIZE=2][COLOR=#0000ff]varchar[/COLOR][/SIZE][SIZE=2](50))[/SIZE]
[SIZE=2][COLOR=#0000ff]AS[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]INSERT INTO [/COLOR][/SIZE][SIZE=2][Names] [/SIZE]
[SIZE=2]([/SIZE]
[SIZE=2][Name], [/SIZE]
[SIZE=2][Notation][/SIZE]
[SIZE=2]) [/SIZE]
[SIZE=2][COLOR=#0000ff]VALUES [/COLOR][/SIZE]
[SIZE=2]([/SIZE]
[SIZE=2]@Name, [/SIZE]
[SIZE=2]@Notation[/SIZE]
[SIZE=2])[/SIZE]
I tried the blasted thing also with a sqlCommand, but with the same results (or lack of).