hugohilario Posted September 16, 2003 Posted September 16, 2003 Hi, With vb 6.0 i can do this, set a control source to a textbox: Dim li As New ADODB.Connection Dim dados As New ADODB.Recordset Dim strSQL As String li.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=\Desenvolvimento\Rh Vb v.1.0\rh.mdb;Persist Security Info=False" li.CursorLocation = ADODB.CursorLocationEnum.adUseClient strSQL = "select * from t_users_logs" li.Mode = ADODB.ConnectModeEnum.adModeReadWrite li.Open dados.Open "t_users_logs", li, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic dados.MoveFirst Me.Textbox1.DataField = "user_id" dados.MoveFirst Set Me.Textbox1.DataSource = dados All I want to do is this with vb.net, but the property .datafield can't be assigned, it's not available in code. Quote
Moderators Robby Posted September 16, 2003 Moderators Posted September 16, 2003 Paste this into the code window of a form.... The controls are: txt = textbox btn = button Dim dt As DataTable Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click Dim cm As CurrencyManager = BindingContext(dt) cm.Position -= 1 End Sub Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click Dim cm As CurrencyManager = BindingContext(dt) cm.Position += 1 End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Const sConn As String = "Data Source=127.0.0.1;Initial Catalog=northwind;Integrated Security=True" Dim sSQL As String = "Select EmployeeID, FirstName + ' ' + LastName AS FullName from Employees " Dim da As New SqlClient.SqlDataAdapter(sSQL, sConn) Dim ds As New DataSet() da.Fill(ds, "EmployeeList") dt = ds.Tables("EmployeeList") txtEmployeeID.DataBindings.Add("Text", dt, "EmployeeID") txtFullName.DataBindings.Add("Text", dt, "FullName") End Sub Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.