databases in vb.net

Microsoft Windows xp professional w/serv...
July 16, 2010 at 08:35:01
Specs: Windows XP, 512mb
hey
i am making a project in vb.net and facing lot of difficulties in databases part
these are statements that i use for inserting in tables..
If RadioButton1.Checked = True Then
gender = "male"
Else
gender = "female"
End If
con = New SqlConnection("Data Source=KJ\SQLEXPRESS;Initial Catalog=GNONE;Integrated Security=True;Pooling=False")
con.Open()
cm = New SqlCommand("insert into STUINFO VALUES(@p1,@ROLLNO,@BRANCH,@COURSE,@FATHERNAME,@MOTHERNAME,@DOB,@DOA,@GENDER,@SEM,@FEE,@PADD,@CADD,@PHONE,@MOB,@PHOTO,@CAT)", con)
cm.Parameters.Add(New SqlParameter("p1", SqlDbType.VarChar, 50))
cm.Parameters.Add(New SqlParameter("ROLLNO", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("BRANCH", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("COURSE", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("FATHERNAME", SqlDbType.VarChar, 50))
cm.Parameters.Add(New SqlParameter("MOTHERNAME", SqlDbType.VarChar, 50))
cm.Parameters.Add(New SqlParameter("DOB", SqlDbType.DateTime))
cm.Parameters.Add(New SqlParameter("DOA", SqlDbType.DateTime))
cm.Parameters.Add(New SqlParameter("GENDER", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("SEM", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("FEE", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("PADD", SqlDbType.VarChar, 50))
cm.Parameters.Add(New SqlParameter("CADD", SqlDbType.VarChar, 50))
cm.Parameters.Add(New SqlParameter("PHONE", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("MOB", SqlDbType.VarChar, 10))
cm.Parameters.Add(New SqlParameter("PHOTO", SqlDbType.VarChar))
cm.Parameters.Add(New SqlParameter("CAT", SqlDbType.VarChar, 50))
cm.Parameters(0).Value = TXTSTUNAME.Text
cm.Parameters(1).Value = TXTSTUROLL.Text
cm.Parameters(2).Value = LSTBRANCH.SelectedItem
cm.Parameters(3).Value = LSTCOURSE.SelectedItem
cm.Parameters(4).Value = TextBox14.Text
cm.Parameters(5).Value = TextBox13.Text
cm.Parameters(6).Value = DateTimePicker3.Value.ToShortDateString
cm.Parameters(7).Value = DateTimePicker2.Value.ToShortDateString
cm.Parameters(8).Value = gender
cm.Parameters(9).Value = LSTSEM.SelectedItem
cm.Parameters(10).Value = MaskedTextBox3.Text
cm.Parameters(11).Value = TextBox5.Text
cm.Parameters(12).Value = TextBox6.Text
cm.Parameters(13).Value = MaskedTextBox4.Text
cm.Parameters(14).Value = MaskedTextBox6.Text
cm.Parameters(15).Value = PictureBox1.ImageLocation
cm.Parameters(16).Value = LSTCAT.SelectedItem

cm.executeNonQuery

it shows error on the statement cm.executenonquery and prog execution stops there but entries in table are made
and if i don't use it entries are not made
pleeeease kindly help


See More: databases in vb.net

Report •

#1
July 18, 2010 at 04:03:56
Your code appears valid. What error do you get?

Report •
Related Solutions


Ask Question