Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Database > Database General Discussion

Database General Discussion General discussion on database related topics

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-20-2008, 2:30 PM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Oct 2008
Posts: 49
Reputation: 20
Nader is on a distinguished programming path ahead
Question Select problem from DB Ms access to TextBox

I tried this code and it succeed only for one textbox but it didn't succeed for tow textboxes

Dim cmd AsNew OleDbCommand
cmd.Connection = conn
conn.Open()
cmd.CommandText = " SELECT Name,Place FROM TBaccount
TextBox1.Text = cmd.ExecuteScalar
TextBox2.Text = cmd.ExecuteScalar

conn.Close()

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-20-2008, 4:08 PM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 875
Reputation: 499
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

This process sounds lengthy but takes about 30 seconds.

Select Data --> Add New Data Source
Choose Database and click Next
Click the New Connection button
Click the Change button next to data source
---
If it's a .mdb file you can select Microsoft Access Database File and click OK
---
If it's a .accdb file select <other> from the Data source: list box
Select .NET Framework Data Provider for OLE DB
Click OK
Select Microsoft Office 12.0 Access Database Engine OLE DB Provider
---
Put the full path to your database in the Enter a server or file name: box
Click the Test Connection box to make sure everything is set up correctly.
Click OK
Click Next
Name your connection string something meaningful and click Next
Select the fields you want in your DataSet.
Name your DataSet
Click Finish

You should now have your DataSet in the Data Sources window. If you can't see it click Data --> Show Data Sources.

Click the name of the table in the data set and then click on the drop down arrow. Change it from DataGridView to Details.

Drag the table onto your form.

Visual Studio will create a BindingSource, TableAdapter, and BindingNavigator for you. You'll also see a label with the column name and textbox for each column in your DataSet.

Run your program. Enjoy writing 0 code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-21-2008, 7:23 AM
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Oct 2008
Posts: 49
Reputation: 20
Nader is on a distinguished programming path ahead
Default

I'm using thie code in module and called from Sub. Your way will not service me.

Here is the solution

Dim sql AsString = "Select Name,Company FROM TBaccount"

Dim cmd AsNew OleDbCommand(sql, conn)
Dim dr As OleDbDataReader
conn.Open()
dr = cmd.ExecuteReader
DoWhile dr.Read
Form1.TextBox1.Text = dr("Name")
Form1.TextBox2.Text = dr("Company")
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-21-2008, 10:56 AM
VB.NET Forum Idol
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Feb 2008
Location: USA
Posts: 875
Reputation: 499
MattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond reputeMattP has a reputation beyond repute
Default

/sigh...you can lead a horse to water.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-28-2008, 9:38 PM
cjard's Avatar
VB.NET Forum All-Mighty
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Apr 2006
Age: 65
Posts: 6,442
Reputation: 807
cjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond reputecjard has a reputation beyond repute
Default

Nader, take a read of the DW2 link in my signature, section "Creating a Simple Data App"

Quote:
Originally Posted by MattP
/sigh...you can lead a horse to water
__________________
DW1 DW2 DW3 DW4 DNU PQ
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 7:35 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.