Hello to all,
I am Using: SQL Server 2014, VS2015, VB, WIN FORMS.
1. I need to update the SQL Server with the values that are entered into the Textbox.
2. I have a textbox where I enter an Asset Number and I click a Search Button and it populates the Datagridview control with the results.
The Code Used for #2 is:
3. The Datagridview populates correctly with the data.
4. I Click on a row in the Datagridview and it populates several Textboxes with the corresponding values.
The Code Used for # 4 is:
5. I would like to make changes in the Textboxes and be able to Click an Update Button to update the new values to the SQL Server. This is where I am stuck.
Regards and Thank you,
I am Using: SQL Server 2014, VS2015, VB, WIN FORMS.
1. I need to update the SQL Server with the values that are entered into the Textbox.
2. I have a textbox where I enter an Asset Number and I click a Search Button and it populates the Datagridview control with the results.
The Code Used for #2 is:
Using connection As New SqlConnection("SERVER=x.x.x.x;database=ITDatabase;trusted_connection=yes;")
Dim cmd As New SqlCommand("SELECT AssetNo [ASSET NO.], t2.TYPE [TYPE], t3.Status [STATUS]
From ASSETINFO t1
INNER Join TypeInfo t2 on t1.TYPEID = t2.TYPEID
INNER Join STATUSINFO t3 on t1.STATUSID = t3.STATUSID
WHERE AssetNo Like '%" + txtSearchData.Text + "%' Order By AssetNo ASC;", connection)
Dim Adpt As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
If (Adpt.Fill(ds, "EQUIPINFO")) Then
dataGridAssetEdit.DataSource = ds.Tables(0)
End If
Else
MessageBox.Show("Record(s) not found.")
End If
End Using
Dim cmd As New SqlCommand("SELECT AssetNo [ASSET NO.], t2.TYPE [TYPE], t3.Status [STATUS]
From ASSETINFO t1
INNER Join TypeInfo t2 on t1.TYPEID = t2.TYPEID
INNER Join STATUSINFO t3 on t1.STATUSID = t3.STATUSID
WHERE AssetNo Like '%" + txtSearchData.Text + "%' Order By AssetNo ASC;", connection)
Dim Adpt As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
If (Adpt.Fill(ds, "EQUIPINFO")) Then
dataGridAssetEdit.DataSource = ds.Tables(0)
End If
Else
MessageBox.Show("Record(s) not found.")
End If
End Using
3. The Datagridview populates correctly with the data.
4. I Click on a row in the Datagridview and it populates several Textboxes with the corresponding values.
The Code Used for # 4 is:
If e.ColumnIndex >= 0 AndAlso e.RowIndex >= 0 Then
txtAssetNo2.Text = dataGridAssetEdit.Rows(e.RowIndex).Cells(0).Value.ToString
cboAssetType2.Text = dataGridAssetEdit.Rows(e.RowIndex).Cells(1).Value.ToString
cbostatus2.Text = dataGridAssetEdit.Rows(e.RowIndex).Cells(2).Value.ToString
End If
txtAssetNo2.Text = dataGridAssetEdit.Rows(e.RowIndex).Cells(0).Value.ToString
cboAssetType2.Text = dataGridAssetEdit.Rows(e.RowIndex).Cells(1).Value.ToString
cbostatus2.Text = dataGridAssetEdit.Rows(e.RowIndex).Cells(2).Value.ToString
End If
5. I would like to make changes in the Textboxes and be able to Click an Update Button to update the new values to the SQL Server. This is where I am stuck.
Regards and Thank you,