Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15107

VS 2008 problem in adding data

$
0
0
pls need guide sir,

heres my code; thank you in advance


ineed result like this..
Code:

room    subject
a          mathe
a          english
not like this
room    subject
a          mathe
a          mathe


Code:

cmd = con.CreateCommand()
            cmd.CommandType = CommandType.Text
            cmd = New SqlCommand("Select * from tblschedule where room like '%" & TextBox2.Text & "%'", con)
            cmd.ExecuteNonQuery()


         
            Dim sda As SqlDataReader = cmd.ExecuteReader
            Dim ds As New DataSet
            sda.Read()
            If Val(TextBox3.Text = ds.Tables("tblschedule").Rows(0)("subject").count) > 1 Then
                MsgBox("subject Already Exist", MessageBoxIcon.Error, "Error")



            Else

                cmd = con.CreateCommand()
                cmd.CommandType = CommandType.Text
                cmd = New SqlCommand("schedule_class", con)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("@room", TextBox2.Text.ToUpper.Trim)
                cmd.Parameters.AddWithValue("@yearlevel", TextBox1.Text.ToUpper.Trim)
                cmd.Parameters.AddWithValue("@time", ComboBox2.Text.ToUpper.Trim)
                cmd.Parameters.AddWithValue("@subject", TextBox3.Text.ToUpper.Trim)
                cmd.Parameters.AddWithValue("@teacher", TextBox4.Text.ToUpper.Trim)

                cmd.ExecuteNonQuery()
                MsgBox("Save Sucessfully!", MessageBoxIcon.Information, "Success")


Viewing all articles
Browse latest Browse all 15107

Trending Articles