Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem sa upisom u tabelu

[es] :: MS SQL :: Problem sa upisom u tabelu

[ Pregleda: 372 | Odgovora: 4 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

CallMeSaMaster
Sarajevo

Član broj: 43611
Poruke: 371
*.PPPoE-2589.sa.bih.net.ba.



Profil

icon Problem sa upisom u tabelu07.08.2006. u 14:17

Moze li molim vas neko pomoci.
Imam tabelu sa sledecim elementima

ID VerbID Jezik Verb Verborder
------------------------------------------
1 1 en play 1
2 1 hr igra 1

na stranici imam mali dropdownbox iz kojeg izabrati verb npr.igrati,citati itd...

Na button click zelim da mi se u tu tabelu upisu vrijednosti izabrane iz boxa ali mi se cini da se sve odradi ok ali nista se ne upise u bazu
Pritome je ID Autoincrement a VerbID moze biti null

Evo source code

Private Sub Add_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Add.Click

Dim MyCommand As SqlCommand

MyCommand = New SqlCommand("InsertVerb", MyConnection)
MyCommand.CommandType = CommandType.StoredProcedure
With MyCommand.Parameters
.Add(New SqlParameter("@LanguageID", SqlDbType.Int)).Value = en
.Add(New SqlParameter("@Verb", SqlDbType.NVarChar, 50)).Value = Verbs.ItemSelected.Text
.Add(New SqlParameter("@Verborder", SqlDbType.NVarChar, 50)).Value = 1
End With


I napisao sam sledecu stored procedure
CREATE PROCEDURE InsertVerb
@LanguageID varchar(5),
@Verb nvarchar(30),
@VerbOrder int

As
BEGIN
BEGIN TRAN
INSERT INTO Verb
(
LanguageID,
Verb,
Verborder
)
VALUES
(
@LanguageID,
@Verb,
@Verborder
)
COMMIT TRAN
END
Go
07.08.2006. u 14:17 

Fedya
Fedor Hajdu
Senior Software Engeneer, Ammado Internet Services
Novi Sad

Član broj: 28246
Poruke: 627
*.ADSL.neobee.net.

Jabber: fedya@elitesecurity.org
Sajt: www.ammado.com


Profil

icon Re: Problem sa upisom u tabelu07.08.2006. u 14:22
MyCommand.ExecuteNonQuery()
I am currently away on leave, traveling through time and will be returning last week.
07.08.2006. u 14:22 

CallMeSaMaster
Sarajevo

Član broj: 43611
Poruke: 371
*.PPPoE-2589.sa.bih.net.ba.



Profil

icon Re: Problem sa upisom u tabelu07.08.2006. u 14:27
preptostavljo sam da je to ali ne znam gdje treba staviti i treba li mi jos nesto?-Tipa MyCommand.Connection.Open()

Mozes li i molim te napisati sta tacno trebam dodati?
Hvala ti
07.08.2006. u 14:27 

Fedya
Fedor Hajdu
Senior Software Engeneer, Ammado Internet Services
Novi Sad

Član broj: 28246
Poruke: 627
*.ADSL.neobee.net.

Jabber: fedya@elitesecurity.org
Sajt: www.ammado.com


Profil

icon Re: Problem sa upisom u tabelu07.08.2006. u 14:34
Znaci posle endwith:
try{
MyCommand.Connection.Open()
MyCommand.ExecuteNonQuery()
}
catch(Exception)
{//obradis exception...
}
finally
{
MyCommand.Connection.Close()
}

Verujem da je to sve.

(Ne znam tacnu sintaksu za VB, ali misim da neces imati problema)
I am currently away on leave, traveling through time and will be returning last week.
07.08.2006. u 14:34 

CallMeSaMaster
Sarajevo

Član broj: 43611
Poruke: 371
*.PPPoE-2589.sa.bih.net.ba.



Profil

icon Re: Problem sa upisom u tabelu07.08.2006. u 14:35
DA to je to.
Hvala na pomoci iako sam bio blizu da skontam.Zaboravio sam connection close na kraju:)
Ali hvala jos jednom.
07.08.2006. u 14:35 

[es] :: MS SQL :: Problem sa upisom u tabelu

[ Pregleda: 372 | Odgovora: 4 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.