Inserting Data into SQL table

unable to insert the data into table from the vb.net form ....

Page 1 of 1

2 Replies - 2279 Views - Last Post: 21 July 2008 - 10:10 AM Rate Topic: -----

#1 laghate_rohan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-July 08

Inserting Data into SQL table

Post icon  Posted 21 July 2008 - 05:42 AM

I am doing database connectivity through Drag and Drop..and writing queries in the query builder..am unable to add ne data in the database table...here is the code...kindly help me rectify it...

when i click on save..the data should be saved in the table under appropriate clms...


Dim eid As String
		If flag = 1 Then
			dt = Ds1.Tables("TBLENQUIRY")
			dr = dt.NewRow()
			dr(0) = txteid.Text
			dr(1) = txtfname.Text
			dr(2) = txtmname.Text
			dr(3) = txtlname.Text
			dr(4) = txtdob.Text
			dr(5) = chkm.Tag
			dr(6) = cmb8.SelectedItem
			dr(7) = cmb9.SelectedItem
			dr(8) = txtaddress.Text
			dr(9) = txtresidence.Text
			dr(10) = txtmobile.Text
			dr(11) = txtemail.Text
			dr(12) = cmb4.SelectedItem
			dr(13) = txtbyop.Text
			dr(14) = cmb6.SelectedItem
			dr(15) = txthyop.Text
			dr(16) = txtanyother.Text
			dr(17) = cmb1.SelectedItem
			dr(18) = rdfull.Tag
			dr(19) = cmb2.SelectedItem
			dr(20) = cmb3.SelectedItem
			dt.Rows.Add(dr)
			txteid.Enabled = True
		ElseIf flag = 2 Then
			dr.Delete()
		ElseIf flag = 3 Then
			dt = Ds1.Tables("TBLENQUIRY")
			dr = dt.Rows.Find(eid)
			dr.BeginEdit()

			dr(0) = txteid.Text
			dr(1) = txtfname.Text
			dr(2) = txtmname.Text
			dr(3) = txtlname.Text
			dr(4) = txtdob.Text
			dr(5) = chkm.Tag
			dr(6) = cmb8.SelectedItem
			dr(7) = cmb9.SelectedItem
			dr(8) = txtaddress.Text
			dr(9) = txtresidence.Text
			dr(10) = txtmobile.Text
			dr(11) = txtemail.Text
			dr(12) = cmb4.SelectedItem
			dr(13) = txtbyop.Text
			dr(14) = cmb6.SelectedItem
			dr(15) = txthyop.Text
			dr(16) = txtanyother.Text
			dr(17) = cmb1.SelectedItem
			dr(18) = rdfull.Tag
			dr(19) = cmb2.SelectedItem
			dr(20) = cmb3.SelectedItem

			txteid.Enabled = True

		End If
		flag = 0
		OleDbDataAdapter1.Update(Ds1, "TBLENQUIRY")
		OleDbDataAdapter1.Fill(Ds1)
		bm.Position = 0



Is This A Good Question/Topic? 0
  • +

Replies To: Inserting Data into SQL table

#2 dineeshd  Icon User is offline

  • member icon

Reputation: 38
  • View blog
  • Posts: 619
  • Joined: 30-June 08

Re: Inserting Data into SQL table

Posted 21 July 2008 - 06:11 AM

Are you getting any error?
Was This Post Helpful? 0
  • +
  • -

#3 gurpreetsingh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-July 08

Re: Inserting Data into SQL table

Posted 21 July 2008 - 10:10 AM

d = Me.DbDataSet.Tables(0).NewRow
		d(0) = TextBox1.Text
		d(1) = TextBox2.Text
		d(2) = TextBox3.Text
		d(3) = TextBox4.Text
		d(4) = TextBox5.Text
		Me.DbDataSet.Tables(0).Rows.Add(d)
		Me.Table1TableAdapter.Update(Me.DbDataSet.Tables(0))
		MsgBox("Data Saved")

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1