Code:
Public Function SelectMaterijaliListIzaberite() As DataTable
Dim strDSN As String = ConfigurationSettings.AppSettings("DSN")
Dim SqlConnection1 As SqlConnection
Dim myCommand As SqlCommand
Dim myTable As New DataTable
myTable.Columns.Add("mid", System.Type.GetType("System.String"))
myTable.Columns.Add("idmaterijala", System.Type.GetType("System.String"))
Dim objDataReader As SqlDataReader
SqlConnection1 = New SqlConnection(strDSN)
myCommand = New SqlCommand("spSelectMaterijaliList", SqlConnection1)
myCommand.CommandType = CommandType.StoredProcedure
SqlConnection1.Open()
myDataReader = myCommand.ExecuteReader()
Dim myDataRow As DataRow
myDataRow = myTable.NewRow()
myDataRow("mid") = "-1"
myDataRow("idmaterijala") = "Izaberite"
myTable.Rows.Add(myDataRow)
Do While (myDataReader.Read)
myDataRow = myTable.NewRow()
myDataRow("mid") = myDataReader.GetSqlInt32(0).ToString
myDataRow("idmaterijala") = myDataReader.GetSqlString(1).ToString & " - " & myDataReader.GetSqlString(2).ToString
myTable.Rows.Add(myDataRow)
Loop
Return myTable
myDataReader.Close()
SqlConnection1.Close()
End Function
To je iz vb-a.
A evo i stored:
Code:
ALTER PROCEDURE [spSelectMaterijaliList]
@i Int = 1
AS
SELECT mid, sifra, grupa, naziv
FROM materijali
WHERE mid <> 0
ORDER BY sifra ASC
A tu je i aspx page load kod koji koristim:
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
Session("page") = "unosporudzbenice"
Session("grupa") = "1"
' ---------------- CHECK IF LOGIN USER ------------------
If Len(CStr(Session("login"))) = 0 Then
'Response.Redirect("../index.aspx")
End If
If Not Page.IsPostBack Then
ddlkupci.DataSource = mykupci.SelectKupciListIzaberite
ddlkupci.DataTextField = "imefirme"
ddlkupci.DataValueField = "kid"
ddlkupci.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid1.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid1.DataTextField = "idmaterijala"
ddlmid1.DataValueField = "mid"
ddlmid1.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid2.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid2.DataTextField = "idmaterijala"
ddlmid2.DataValueField = "mid"
ddlmid2.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid3.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid3.DataTextField = "idmaterijala"
ddlmid3.DataValueField = "mid"
ddlmid3.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid4.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid4.DataTextField = "idmaterijala"
ddlmid4.DataValueField = "mid"
ddlmid4.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid5.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid5.DataTextField = "idmaterijala"
ddlmid5.DataValueField = "mid"
ddlmid5.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid6.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid6.DataTextField = "idmaterijala"
ddlmid6.DataValueField = "mid"
ddlmid6.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid7.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid7.DataTextField = "idmaterijala"
ddlmid7.DataValueField = "mid"
ddlmid7.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid8.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid8.DataTextField = "idmaterijala"
ddlmid8.DataValueField = "mid"
ddlmid8.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid9.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid9.DataTextField = "idmaterijala"
ddlmid9.DataValueField = "mid"
ddlmid9.DataBind()
End If
If Not Page.IsPostBack Then
ddlmid10.DataSource = mymaterijali.SelectMaterijaliListIzaberite
ddlmid10.DataTextField = "idmaterijala"
ddlmid10.DataValueField = "mid"
ddlmid10.DataBind()
End If
If Len(Session("ex")) <> 0 Then
Label6.Text = " *** Unesite ponovo"
End If
Session("ex") = ""
If Len(Session("o")) <> 0 Then
Label6.Text = " *** Izaberite ponovo"
End If
Session("o") = ""
Label1.Text = CStr(Session("idporudzbine"))
Label7.Text = CStr(Session("datumunosa"))
Label21.Text = CStr(Session("datumisteka"))
Label5.Text = CStr(Session("kupac"))
Label10.Text = CStr(Session("iznosporudzbine"))
Label3.Text = CStr(Session("Uneto"))
Label24.Text = CStr(Session("komentar"))
Label8.Text = CStr(Session("valuta"))
Label22.Text = CStr(Session("kupac1"))
Dim intRedniBrojPloce As Integer = 0
If Len(CStr(Session("porid"))) <> 0 Then
intRedniBrojPloce = mystavkeporudzbine.GetZadnjuStavkuporudzbine(CInt(Session("porid")))
myporudzbine.SelectPorudzbine(CInt(Session("porid")))
Session("idporudzbine") = CStr(myporudzbine.idporudzbine)
Label1.Text = CStr(myporudzbine.idporudzbine)
Session("datumunosa") = CStr(myporudzbine.datumunosa)
Label7.Text = CStr(Session("datumunosa"))
Session("datumisteka") = CStr(myporudzbine.datumisteka)
Label21.Text = CStr(Session("datumisteka"))
mykupci.SelectKupci(mykupci.kid)
Session("kupac") = CStr(mykupci.imefirme)
Label5.Text = CStr(Session("kupac"))
mykupci.SelectKupci(myporudzbine.kid)
Session("kupac1") = CStr(mykupci.imeiprezime)
Label22.Text = CStr(Session("kupac1"))
Session("komentar") = CStr(myporudzbine.komentar)
Label24.Text = CStr(Session("komentar"))
Session("Uneto") = "Uneto"
Label3.Text = CStr(Session("Uneto"))
Session("v") = CStr(myporudzbine.valuta)
Select Case myporudzbine.valuta
Case Is = 1
Session("valuta") = "_ " & "D - Dinar" & " "
Case Is = 2
Session("valuta") = "_ " & "€ - Euro" & " "
Case Is = 3
Session("valuta") = "_ " & "$ - US Dolar" & " "
End Select
Label8.Text = CStr(Session("valuta"))
Session("iznosporudzbine") = CStr(myporudzbine.iznosporudzbine)
Label10.Text = CStr(Session("iznosporudzbine"))
End If
Session("rbstavke") = CStr(intRedniBrojPloce)
If intRedniBrojPloce <> 0 Then
Label11.Text = CStr(intRedniBrojPloce + 1)
Label12.Text = CStr(intRedniBrojPloce + 2)
Label13.Text = CStr(intRedniBrojPloce + 3)
Label14.Text = CStr(intRedniBrojPloce + 4)
Label15.Text = CStr(intRedniBrojPloce + 5)
Label16.Text = CStr(intRedniBrojPloce + 6)
Label17.Text = CStr(intRedniBrojPloce + 7)
Label18.Text = CStr(intRedniBrojPloce + 8)
Label19.Text = CStr(intRedniBrojPloce + 9)
Label20.Text = CStr(intRedniBrojPloce + 10)
Else
Label11.Text = CStr(1)
Label12.Text = CStr(2)
Label13.Text = CStr(3)
Label14.Text = CStr(4)
Label15.Text = CStr(5)
Label16.Text = CStr(6)
Label17.Text = CStr(7)
Label18.Text = CStr(8)
Label19.Text = CStr(9)
Label20.Text = CStr(10)
End If
End Sub
Bas me zanima gde je greska. Ja sam samo nastavio strukturu programa koju je drugi programer napisao, dodavao pretrazivace i nove objekte, glavni kod i strukturu je on postavio, ali pre 4 godine tj mozda i 5 i to je bilo na iis 5.1 i radilo sa sql 2000.