Im new to VB 2005. Seeking for kind advise.
With refer to my code below, why is my pointer always refering to record no.1 on textbox1.text? No matter which record i clicked, i will still getting data of username from first record. Anything i Missed out?
Curiously to ask, is that possible to apply .addnew command and .update command rather than using SQL command of "Update username ..." with using below namespace.
Thank you in advance.
Regards,
Beautieee.
With refer to my code below, why is my pointer always refering to record no.1 on textbox1.text? No matter which record i clicked, i will still getting data of username from first record. Anything i Missed out?
Curiously to ask, is that possible to apply .addnew command and .update command rather than using SQL command of "Update username ..." with using below namespace.
Thank you in advance.
Regards,
Beautieee.
Code:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Dim objConnection As New SqlConnection(ConnectT)
Dim objDataAdapter As New SqlDataAdapter()
Dim objDataSet As New DataSet()
Dim objDataView As DataView
Dim objCurrencyManager As CurrencyManager
Dim objCommand As New SqlCommand()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set the SelectCommand properties...
objConnection.Open()
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = "SELECT * from usertable"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
' Open the database connection...
'objConnection.Open()
' Fill the DataSet object with data...
objDataAdapter.Fill(objDataSet, "usertable")
objDataView = New DataView(objDataSet.Tables("usertable"))
objCurrencyManager = _
CType(Me.BindingContext(objDataView), CurrencyManager)
' Close the database connection...
'objConnection.Close()
' Set the DataGridView properties to bind it to our data...
grdAuthorTitles.AutoGenerateColumns = True
grdAuthorTitles.DataSource = objDataSet
grdAuthorTitles.DataMember = "usertable"
' Clean up
'objDataAdapter = Nothing
'objConnection = Nothing
End Sub
Private Sub grdAuthorTitles_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grdAuthorTitles.CellDoubleClick
TextBox1.DataBindings.Clear()
TextBox1.DataBindings.Add("Text", objDataView, "username")
End Sub