i'm getting an error when i'm trying to update my database
Syntax error in UPDATE statement
item:In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
error code: -2147217900
errors: {System.Data.OleDb.OleDbErrorCollection}
Imports System.Data.OleDb
Public Class Ubah_Password
Dim kns As New OleDbConnection("provider=microsoft.ace.oledb.15.0;data source =" & Application.StartupPath & "\database.accdb")
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim sql As String
Sub tampilkan() 'menampilkan semua user
ds.Clear()
sql = "SELECT * FROM USERLIST"
da.SelectCommand = New OleDbCommand(sql, kns)
da.Fill(ds, "USERLIST")
End Sub
Sub cariid() 'mencari id
ds.Clear()
sql = "select * from USERLIST where USERNAME = '" & LOGIN.USERNAME.Text & "'"
da.SelectCommand = New OleDbCommand(sql, kns)
da.Fill(ds, "USERLIST")
End Sub
Sub gantiid() 'mengganti password
sql = "update USERLIST set USERNAME = '" & LOGIN.USERNAME.Text & "', PASSWORD= '" & renew.Text & "' where USERNAME ='" & LOGIN.USERNAME.Text & "'"
kns.Open()
da.UpdateCommand = New OleDbCommand(sql, kns)
da.UpdateCommand.ExecuteNonQuery()
kns.Close()
End Sub
Private Sub Ubah_Password_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
MAIN_MENU.Panel1.Visible = True
End Sub
Private Sub Ubah_Password_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tampilkan()
MAIN_MENU.Panel1.Visible = False
End Sub
Private Sub oldpass_TextChanged(sender As Object, e As EventArgs) Handles oldpass.TextChanged
cariid()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cariid()
If ds.Tables("USERLIST").Rows.Count = 0 Then
MessageBox.Show("You Have Enter Wrong Password", "Warning!")
oldpass.Clear()
newpass.Clear()
renew.Clear()
oldpass.Focus()
ElseIf ds.Tables("USERLIST").Rows.Count = 1 And newpass.Text <> renew.Text Then
MessageBox.Show("New Password And Confirmation Must Be Same!", "Warning!")
newpass.Clear()
renew.Clear()
newpass.Focus()
ElseIf ds.Tables("USERLIST").Rows.Count = 1 And newpass.Text = renew.Text Then
gantiid()
MessageBox.Show("Password Change Is Successful!", "Notice")
Me.Close()
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
Related
Anyone can help me with this please ?
The app you see rn is nothing like the app im working on , i made it way simple.
** because of the versions ?? I'm using VB.net2017 / Ms-AccessDb 2010**
this code below is a simple version that i made , of my main app that im working on , because my main code has too many radio buttons( equipments status to check if they on or fail ) and more than 15 textbox , and i did put them in same Db table as columns that the insert query looks so long in vb , cuz i didnt know any other method , and i dont want create the gridviewcolumns myself because i got over 50 columns that would be long , i just need to use simple code as possible .
the thing is , i keep getting the errors in these lines below :
connection.open() [error said cant find the file , but my file path is not wrong]
mycommand.CommandText = "INSERT INTO Status (.... ect )
mycommand.ExecuteNonQuery() [ error : exception .... ]
da.Fill(ds, "[Status]") [also error in the select query coudnt find the table or incorrect file name ]
pic1(click me): example of error i keep getting
pic2 : the simple form1 with it code below .
pic3 : my Ms-AccessDb
Imports System.Data.OleDb
Public Class Form1
Dim s1 As Boolean
Dim s2 As Boolean
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label_currentdate.Text = DateTime.Now.ToString()
End Sub
Private Sub BTN_Save_Click(sender As Object, e As EventArgs) Handles BTN_Save.Click
Dim myconnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data source=C:\Users\acer\Desktop\ABC.accdb")
Dim mycommand As OleDbCommand = myconnexion.CreateCommand()
myconnexion.Open()
mycommand.CommandText = "INSERT INTO Status (item-Number,CurrentDate,Employee_Name,Equip2 status,Equip1 status)
VALUES('" & Label_items.Text & "','" & Label_currentdate.Text & "','" & TextBox_EmployeeName.Text & "','" & s1 & "','" & s2 & "')"
mycommand.ExecuteNonQuery()
MsgBox(" successfully saved !")
myconnexion.Close()
End Sub
Private Sub RB1_CheckedChanged(sender As Object, e As EventArgs) Handles RB1.CheckedChanged
s1 = True
End Sub
Private Sub RB2_CheckedChanged(sender As Object, e As EventArgs) Handles RB2.CheckedChanged
s1 = False
End Sub
Private Sub RB3_CheckedChanged(sender As Object, e As EventArgs) Handles RB3.CheckedChanged
s2 = True
End Sub
Private Sub RB4_CheckedChanged(sender As Object, e As EventArgs) Handles RB4.CheckedChanged
s2 = False
End Sub
Private Sub BTN_reset_Click(sender As Object, e As EventArgs) Handles BTN_reset.Click
Dim RB As RadioButton
TextBox_EmployeeName.Text = ""
For Each RB In GBX1.Controls
RB.Checked = False
Next
For Each RB In GBX2.Controls
RB.Checked = False
Next
End Sub
Private Sub Label_currentdate_Click(sender As Object, e As EventArgs)
End Sub
Private Sub BTN_History_Click(sender As Object, e As EventArgs) Handles BTN_History.Click
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim table As DataTableCollection
Dim source1 As New BindingSource
'
'
conn = New OleDbConnection With {.ConnectionString = "provider=Microsoft.ACE.OLEDB.12.0;Data source=C:\Users\acer\Desktop\ABC.accdb"}
ds = New DataSet
table = ds.Tables
da = New OleDbDataAdapter("Select * from [Status]", conn)
da.Fill(ds, "[Status]")
Dim view As New DataView(table(0))
source1.DataSource = view
DataGridView.DataSource = view
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label_items.Text = "item number 1 "
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Label_items.Text = "item number 2"
End Sub
End Class
You can't have spaces in field names, and a date value must be formatted properly. Also, Status may be a reserved word, and - if s1 and s2 are numeric - no quotes:
Label_currentdate.Text = DateTime.Today.ToString("yyyy'/'MM'/'dd")
<snip>
mycommand.CommandText = "INSERT INTO [Status] ([item-Number],CurrentDate,Employee_Name,[Equip2 status],[Equip1 status])
VALUES('" & Label_items.Text & "',#" & Label_currentdate.Text & "#,'" & TextBox_EmployeeName.Text & "'," & s1 & "," & s2 & ")"
But do consider using parameters. Much cleaner and simpler to maintain.
my problem is how to search data and update it in ms access and vb.net
my code:
Imports System.Data.OleDb
Public Class Form5
Dim provider As String
Dim dataFile As String
Dim connString As String
Public myConnection As OleDbConnection = New OleDbConnection
Public dr As OleDbDataReader
Private Sub Form5_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source ="
dataFile = "C:\Users\Admin\Desktop\project database\Database5.accdb"
connString = provider & dataFile
myConnection.ConnectionString = connString
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
myConnection.Open()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox9.Clear()
TextBox10.Clear()
TextBox11.Clear()
Dim str As String
str = "SELECT * FROM registration WHERE (Name = '" & TextBox1.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
dr = cmd.ExecuteReader
While dr.Read()
TextBox2.Text = dr("No").ToString
TextBox3.Text = dr("Name").ToString
TextBox4.Text = dr("Age").ToString
TextBox5.Text = dr("Gender").ToString
TextBox6.Text = dr("Phone").ToString
TextBox7.Text = dr("Address").ToString
TextBox8.Text = dr("Desease").ToString
TextBox9.Text = dr("RoomNo").ToString
TextBox10.Text = dr("Building").ToString
TextBox11.Text = dr("RoomType").ToString
End While
myConnection.Close()
End Sub
End Class
the error I'm getting:
"No value given for one or more required parameters."}
Isn't the issue here that when you click button3 you clear the textbox1 where I assume you type the name you wish to search. So its throwing you an error that there is nothing in that field. And even if you type something after wards, and click the button again, it will clear it again before it starts searching. so basically, you're searching for nothing.
Can some one please assist me? How to get rid of this error?
concurrency violation : Updated 0 of the expected 1 records
I have been struggling with the update command for the last couple of days. I tried many solutions from the internet but I am unable to resolve this issue.
Imports Microsoft.Office
Imports System.Data.OleDb
Public Class Form1
Dim dt As New DataTable
Dim cnn As New OleDb.OleDbConnection
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'filling analyst filter
Dim sText As String = String.Empty
Dim sConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\ecxx-store\Exxx xxxxsk\Txx Axxx\Enxx Flxxx\Source\Exx_Exxx_Flagging.accdb" 'Put your connection string in here
Using cn As New OleDb.OleDbConnection(sConnString)
cn.Open()
Dim cmd As New OleDb.OleDbCommand("SELECT Distinct Analyst FROM EF ORDER BY Analyst", cn)
Dim r As OleDb.OleDbDataReader = cmd.ExecuteReader()
While r.Read()
ComboBox7.Items.Add(r("analyst"))
End While
r.Close()
cn.Close()
End Using
'end of filling analyst filter
Me.EFTableAdapter.Fill(Me.Exx_Exxxx_ShippingDataset.EF)
Me.Label19.Text = "Welcome " & StrConv(Environment.MachineName, vbProperCase)
Me.Label20.Text = EFBindingSource.Count.ToString() & " entries"
'Setting Followup Status
Me.ComboBox8.Text = "Waiting for approval"
'disabling Second Analyst Details
Me.txtsecondanalyst.Enabled = False
Me.txtapproval.Enabled = False
Me.txtnotes.Enabled = False
End Sub
Private Sub txtdof_ValueChanged(sender As Object, e As EventArgs) Handles txtdof.ValueChanged
Me.txtnd.Text = DateDiff(DateInterval.Day, CDate(txtdof.Text), Now())
End Sub
Private Sub ComboBox7_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox7.SelectedIndexChanged
If IsNothing(Me.ComboBox8.Text) Then
EFBindingSource.Filter = "[Analyst] LIKE '%" & ComboBox7.Text & "%'"
Else
EFBindingSource.Filter = "[FollowupStatus] LIKE '%" & ComboBox8.Text & "%' AND [Analyst] Like '%" & ComboBox7.Text & "%'"
End If
'count of datagrid
Me.Label20.Text = EFBindingSource.Count.ToString() & " entries"
End Sub
Private Sub ComboBox8_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox8.SelectedIndexChanged
If IsNothing(Me.ComboBox7.Text) Then
EFBindingSource.Filter = "[FollowupStatus] LIKE '%" & ComboBox8.Text & "%'"
Else
EFBindingSource.Filter = "[FollowupStatus] LIKE '%" & ComboBox8.Text & "%' AND [Analyst] Like '%" & ComboBox7.Text & "%'"
End If
'count of datagrid
Me.Label20.Text = EFBindingSource.Count.ToString() & " entries"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'update
Me.txtnd.Visible = True
Me.txtnd.Text = DateDiff(DateInterval.Day, CDate(txtdof.Text), Now())
On Error GoTo SaveErr
EFBindingSource.EndEdit()
EFTableAdapter.Update(Exx_Exxxx_ShippingDataset.EF)
Me.txtsecondanalyst.Enabled = False
Me.txtapproval.Enabled = False
Me.txtnotes.Enabled = False
MsgBox("Record Updated or Saved")
SaveErr:
End Sub
Private Sub Form1_Closed(sender As Object, e As EventArgs) Handles Me.Closed
EFBindingSource.EndEdit()
Me.TableAdapterManager1.UpdateAll(Me.Exx_Exxx_ShippingDataset)
End Sub
End Class
According to Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. DB concurrencyException was unhandled
You call
Me.EFTableAdapter.Fill(Me.Exx_Exxxx_ShippingDataset.EF)
in Form_Load, but there is no guarantee that the rows aren't changed by the time you call
EFTableAdapter.Update(Exx_Exxxx_ShippingDataset.EF)
in Button1_Click
In the linked answer,
ADO.Net keeps the value of the column when it was selected from the database. When it performs the update the condition is that none of the columns have changed when you commit.
Perhaps you should call
dt = dt.GetChanges()
immediately before updating in Button1_Click, so that the datatable gets updated with the latest values in the database.
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim cnnOLEDB As New OleDbConnection
Dim cmdOLEDB As New OleDbCommand
Dim cmdInsert As New OleDbCommand
Dim cmdDelete As New OleDbCommand
Dim cmdUpdate As New OleDbCommand
Dim conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\Steven\Desktop\Database.accdb"
Private Sub searchbtn_Click(sender As Object, e As EventArgs) Handles searchbtn.Click
If ssearch.Text <> "" Then
cmdOLEDB.CommandText = "SELECT StudentID from Students Where TP = " & CInt(ssearch.Text)
cmdOLEDB.Connection = cnnOLEDB
Dim rd As OleDbDataReader = cmdOLEDB.ExecuteReader()
If rd.Read = True Then
Form2.Show()
Form2.TextBox1.Text = rd(0).ToString
Else
MessageBox.Show("Information not found in Database")
End If
rd.Close()
End If
Me.Hide()
Form2.Show()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cnnOLEDB.ConnectionString = conn
cnnOLEDB.Open()
End Sub
Private Sub ssearch_TextChanged(sender As Object, e As EventArgs) Handles ssearch.TextChanged
End Sub
Private Sub insertbtn_Click(sender As Object, e As EventArgs) Handles insertbtn.Click
If ssearch.Text <> "" Then
cmdInsert.CommandText = "INSERT INTO Students (StudentID) VALUES (" & ssearch.Text & ");"
cmdInsert.CommandType = CommandType.Text
cmdInsert.Connection = cnnOLEDB
cmdInsert.ExecuteNonQuery()
MsgBox(ssearch.Text & " " & "Record inserted.")
ssearch.Text = ""
Else
MsgBox("Please Enter Student ID")
End If
cmdInsert.Dispose()
End Sub
End Class
As you can see i can insert data into the database but I can't search it. When I run it it show errors on Dim rd As OleDbDataReader = cmdOLEDB.ExecuteReader()
saying:
No value given for one or more required parameters visual basic error
What was my mistake?
First I populated the datagridview by data of sqlserver 2008 database table, now i have muliple rows in datagridview containing data, i am trying to update any row but, in the database table it replaces other rows data by the row data that iam trying to update
the code for update statement is given below
Plz help me
Dim cmd As New SqlCommand("Update EmployeeDetail Set Salary = '" &
dgvEmpDetail.Rows(0).Cells(1).Value & "', Experience ='" &
dgvEmpDetail.Rows(0).Cells(2).Value & "', Skills='" &
dgvEmpDetail.Rows(0).Cells(3).Value
& "' where Emp_ID = '" & dgvEmpDetail.Rows(0).Cells(0).Value & "'", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
You've hard coded the row - dgvEmpDetail.Rows(0).
I imagine you are calling this in a loop. You should do something like:
For i As Integer = 0 To dgvEmpDetail.Rows.Count - 1
Dim cmd As New SqlCommand("Update EmployeeDetail Set Salary = '" & dgvEmpDetail.Rows(i).Cells(1).Value & "', Experience ='" & dgvEmpDetail.Rows(i).Cells(2).Value & "', Skills='" & dgvEmpDetail.Rows(i).Cells(3).Value()& "' where Emp_ID = '" & dgvEmpDetail.Rows(i).Cells(0).Value & "'", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Next
Your code is susceptible to SQL injection. You should put the update SQL in to a stored procedure - its faster and safer!
Protected Sub Page_Load()
If Not Page.IsPostBack Then
' Create a new table.
Dim taskTable As New DataTable("TaskList")
' Create the columns.
taskTable.Columns.Add("Id", GetType(Integer))
taskTable.Columns.Add("Description", GetType(String))
taskTable.Columns.Add("IsComplete", GetType(Boolean))
'Add data to the new table.
For i = 0 To 19
Dim tableRow = taskTable.NewRow()
tableRow("Id") = i
tableRow("Description") = "Task " + i.ToString()
tableRow("IsComplete") = False
taskTable.Rows.Add(tableRow)
Next
'Persist the table in the Session object.
Session("TaskTable") = taskTable
'Bind data to the GridView control.
BindData()
End If
End Sub
Protected Sub TaskGridView_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
TaskGridView.PageIndex = e.NewPageIndex
'Bind data to the GridView control.
BindData()
End Sub
Protected Sub TaskGridView_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs)
'Set the edit index.
TaskGridView.EditIndex = e.NewEditIndex
'Bind data to the GridView control.
BindData()
End Sub
Protected Sub TaskGridView_RowCancelingEdit()
'Reset the edit index.
TaskGridView.EditIndex = -1
'Bind data to the GridView control.
BindData()
End Sub
Protected Sub TaskGridView_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
'Retrieve the table from the session object.
Dim dt = CType(Session("TaskTable"), DataTable)
'Update the values.
Dim row = TaskGridView.Rows(e.RowIndex)
dt.Rows(row.DataItemIndex)("Id") = (CType((row.Cells(1).Controls(0)), TextBox)).Text
dt.Rows(row.DataItemIndex)("Description") = (CType((row.Cells(2).Controls(0)), TextBox)).Text
dt.Rows(row.DataItemIndex)("IsComplete") = (CType((row.Cells(3).Controls(0)), CheckBox)).Checked
'Reset the edit index.
TaskGridView.EditIndex = -1
'Bind data to the GridView control.
BindData()
End Sub
Private Sub BindData()
TaskGridView.DataSource = Session("TaskTable")
TaskGridView.DataBind()
End Sub
</script>
I have a access connection with textbox as data feeder to database change it to SQL if u want. The code is:
Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class Form2
Dim conaccess As New OleDbConnection
Dim conreader As OleDbDataReader
Dim concmd As New OleDbCommand
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGridView1.EditMode = False
conaccess.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;data source=d:\vijay.mdb"
conaccess.Open()
loadGrid()
End Sub
Private Sub loadGrid()
Dim access As String
access = "select * from vijay"
Dim DataTab As New DataTable
Dim DataAdap As New OleDbDataAdapter(access, conaccess)
DataAdap.Fill(DataTab)
DataGridView1.DataSource = DataTab
End Sub
Private Sub new_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles new_btn.Click
Dim no As String
no = "select Max(ID) from vijay"
Dim concmd As New OleDbCommand(no, conaccess)
conreader = concmd.ExecuteReader
If (conreader.Read) Then
If (IsDBNull(conreader(0))) Then
id_txt.Text = "1"
Else
id_txt.Text = conreader(0) + 1
End If
name_txt.Clear()
branch_txt.Clear()
age_txt.Clear()
class_txt.Clear()
gen_txt.Clear()
End If
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer
i = DataGridView1.CurrentRow.Index
Try
id_txt.Text = DataGridView1.Item(0, i).Value
name_txt.Text = DataGridView1.Item(1, i).Value
class_txt.Text = DataGridView1.Item(2, i).Value
gen_txt.Text = DataGridView1.Item(3, i).Value
branch_txt.Text = DataGridView1.Item(4, i).Value
age_txt.Text = DataGridView1.Item(5, i).Value
Catch ex As Exception
End Try
End Sub
Private Sub del_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles del_btn.Click
Dim delcmd As New OleDbCommand("delete from vijay where id=" & id_txt.Text & " ", conaccess)
delcmd.ExecuteNonQuery()
MsgBox("Record is deleted")
loadGrid()
id_txt.Clear()
name_txt.Clear()
branch_txt.Clear()
age_txt.Clear()
class_txt.Clear()
gen_txt.Clear()
End Sub
Private Sub save_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_btn.Click
Dim access As String = String.Format("INSERT INTO vijay (Name,Class,Branch,Gender,Age) VALUES('{0}','{1}','{2}','{3}','{4}')", name_txt.Text, class_txt.Text, branch_txt.Text, gen_txt.Text, age_txt.Text)
concmd.Connection = conaccess
concmd.CommandText = access
concmd.ExecuteNonQuery()
MsgBox("Record Successfully Saved")
loadGrid()
id_txt.Clear()
name_txt.Clear()
branch_txt.Clear()
age_txt.Clear()
class_txt.Clear()
gen_txt.Clear()
End Sub
Private Sub up_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles up_btn.Click
Dim access As String
access = "UPDATE vijay SET Name = '" & name_txt.Text & "', Age = '" & age_txt.Text & "', Gender ='" & gen_txt.Text & "' , Branch ='" & branch_txt.Text & "' , Class = '" & class_txt.Text & "' where id=" & id_txt.Text & ""
Dim cmd As New OleDbCommand(access, conaccess)
cmd.ExecuteNonQuery()
loadGrid()
id_txt.Clear()
name_txt.Clear()
branch_txt.Clear()
age_txt.Clear()
class_txt.Clear()
gen_txt.Clear()
End Sub
End Class
Use looping and parameter (to handle sql injection):
con.Open() 'Open connection to database
'Looping throung dgv
For i As Integer = 0 To dgvEmpDetail.Rows.Count - 1
If IsDBNull(dgvEmpDetail.Rows(i).Cells("Emp_ID").Value) Then Exit For
Dim cmd As New SqlCommand("Update EmployeeDetail Set [Salary] = ?, [Experience]=?, [Skills]=? WHERE [Emp_ID] =?", con)
With cmd.Parameters
.AddWithValue("#Salary", dgvEmpDetail.Rows(i).Cells("Salary").Value )
.AddWithValue("#Experience", dgvEmpDetail.Rows(i).Cells("Experience").Value )
.AddWithValue("#Skills", dgvEmpDetail.Rows(i).Cells("Skills").Value )
.AddWithValue("#Emp_ID", dgvEmpDetail.Rows(i).Cells("Emp_ID").Value )
End With
cmd.ExecuteNonQuery()
Next i
con.Close() 'Close connection with Database