how do i insert data to my sql db?
hii, can any1 plz help me.. am not able to insert data in my db. Each time an error msg is being displayed .. 'incorrect mapping of table' Am sending u my code plz check it.
thx
Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class frmUserDetails
Inherits CSLCore.frmBaseForm
Dim TotalRows As Long
Dim dsStaffData As DataSet = New DataSet
Dim bmUser As BindingManagerBase
Dim cmdString As String = "Select * from Staff"
Dim connString As String = "Data Source=(local);Initial Catalog=SupplyChain;Integrated Security=SSPI;"
Dim myConnection As SqlConnection = New SqlConnection(connString)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmdString, myConnection)
Private Sub frmUserDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
' Open connection
myConnection.Open()
da.Fill(dsStaffData, "Staff")
bmUser = Me.BindingContext(dsStaffData, "Staff")
BindData()
With cboTitle
.Items.Add("Miss")
.Items.Add("Mr")
.Items.Add("Mrs")
End With
'DataGrid1.DataSource = dataSet1.DefaultViewManager
Catch ae As SqlException
MessageBox.Show(ae.Message)
End Try
End Sub
#Region "Add"
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
If cmdAdd.Text = "&Add" Then
DisableNavigation()
bmUser.EndCurrentEdit()
da.Fill(dsStaffData, "Staff")
bmUser.AddNew()
With txtStaffID
'.ReadOnly = False
.Focus()
End With
Else
bmUser.CancelCurrentEdit()
EnableNavigation()
End If
End Sub