Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to query Access from VB.net and Display information in a text box

Posted on 2006-04-21
37
Medium Priority
?
311 Views
Last Modified: 2010-04-23
Hello how is everyone doing today?.

As for me I'm doing pretty good so far and trying to understand VB.net more each day.

Anyhow What I want to do is query a small access DB file that I have and then display the information within
a text box so then afterwards the user can just edit the text box and submit the new information.

So far I'm having trouble passing the data to the textbox, I tried putting the textbox name and that didnt work so
I know there is something wrong that I'm doing.

So i try to keep things simple 2 text boxes only for demonstration purposes lol


Here is a small sample code

//////////////////////////////////////////


 Dim connString As String = " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;"
        Dim myConnection As OleDbConnection = New OleDbConnection ' Stores a connection
        Dim insertCmd As OleDbCommand = New OleDbCommand     'Stores object of OLEDB Command


        myConnection.ConnectionString = connString
        myConnection.Open()


        'Now to create  a search statement

        With insertCmd

            .Connection = myConnection
            .CommandText = " Select User_ID,FName From [Names] " & _
                            " Where User_ID=@User_ID"

            .CommandType = CommandType.Text


            .Parameters.Add(New OleDbParameter("@User_ID", OleDbType.Char, 10))
            .Parameters.Add(New OleDbParameter("@FName", OleDbType.Char, 25))



            .Parameters("@User_ID").Value = txtUser.Text    *****////Here is the problem /////
            .Parameters("@FName").Value = txtFname.Text  ******/// and here too ////


        End With

////////////////////////////

As you can see in the ////.Parameter("@USer_ID") I want to pass the information to a text box///

I know im definetly doing something wrong because I know I use example ////.Parameter("@User_ID").Value = Uservariable to compare the data to what
the user is inserting.
This time though I just want to know how to display the information that I have from the database to a text box...In other words transfer it to the text box
and then have another button to submit the new data :)

/////////////////////////

Also another question ...how in the world do you refresh a dataGrid?....I notice when I do a deletion the datagrid still has the data constant, until I do a new search again and then it clears out.....is there anyway to do this?

/////////////////////////



Thankyou in advance for helping this noob out as always :)


/////////////PS////////
Don't worry about the DB connection I tried it out and it works like a charm
so don't worry about if the DB is connecting or if I can retrieve data, because I already tested them out and also displayed it within
a datagrid....so just giving anyone the heads up :)


0
Comment
Question by:masterat03
  • 18
  • 17
36 Comments
 

Expert Comment

by:kbailey23342
ID: 16510409
masterat03:

Each time you make a change to the datasource for the datagrid (Ie, delete a row, add a row, or modify a row), you have to rebind the datagrid to the datasource in order for the datagrid to reflect that change.

- kbailey23342
0
 

Author Comment

by:masterat03
ID: 16511345
Umm...how would I rebind...the same I binded in the first place?

Sorry But Im a noob at this stuff :(
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16511474
hi maseterat03,

This is so much easier for you to try...  I only use parameters in Update & Insert Statements...

Dim connString As String = " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;"
Dim myConnection As OleDbConnection = New OleDbConnection ' Stores a connection
Dim insertCmd As OleDbCommand = New OleDbCommand     'Stores object of OLEDB Command

above can be written as:

Dim cnOleDb As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")

Private Sub FillData()
Dim drB2B As OleDb.OleDbDataReader
        cnOleDb.Open()
        Dim cmdB2BShip As New OleDb.OleDbCommand("SELECT * From Shipping_B2Bgolf Where id = " & SplitID(2) & "", cnOleDb)
        drB2B = cmdB2BShip.ExecuteReader
        If drB2B.Read Then <~~~~very important
            ShipToTextBox.Text = drB2B("shipname").ToString  <~~~~ name in "" is access field name
            ShipAddressTextBox.Text = drB2B("Shipaddress").ToString
            ShipAddress2TextBox.Text = drB2B("Shipaddress2").ToString
            ShipCityTextBox.Text = drB2B("Shipcity").ToString
            ShipStateTextBox.Text = drB2B("Shipstate").ToString
            ShipZipTextBox.Text = drB2B("Shipzip").ToString
            drB2B.Close()
        End If
        cnOleDb.Close()
End SUb

You can see the definate differences but does the exact same thing.

gl,
Lucas
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:masterat03
ID: 16528218
Sorry I haven't posted in a while ..you know it was the weekend so I was out.
Anyhow I wanted to say is there an easier way on how to put data from access to textbox.

Also can you guys perhaps guide me through this using mystyle of coding ?...it makes it easier for me to understand 100x more
on how to do it
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16528572
well masterat03,  

The code you have written above in first post is VB6, right? Unfortunately, I havent used VB6 IDE for quite some time.  I do know that once you learn the .NET way of handling Ole Db and Access data interchange you might find it more helpful or even easier. The example I gave works 100%, as far as the code above ( your code) , if you are using this code in VB.NET 03 or 05 then you might have issues other than just the data accesss.  For example, if you are using VB.NET framework try this.

__________________________________________________________________________

Your Code:

       X Dim connString As String = " Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;"
       X Dim myConnection As OleDbConnection = New OleDbConnection ' Stores a connection
          Dim insertCmd As OleDbCommand = New OleDbCommand     'Stores object of OLEDB Command
       X myConnection.ConnectionString = connString

This can be written as with your information easily, X means you can remove those lines to make below, you can also call this one time and reference it many times.

         Dim myConnection As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")

__________________________________________________________________________

         myConnection.Open()  'This is good
__________________________________________________________________________

         'Now to create  a search statement
         With insertCmd
            .Connection = myConnection
            .CommandText = " Select User_ID,FName From [Names] " & _
                            " Where User_ID=@User_ID"
            .CommandType = CommandType.Text

Two things here. Creating the command does not require the With parameter anymore. Simply put it in something like below.  

          Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From [Names] Where User_ID=@User_ID"", myConnection)

The above is using your SQL statement. The only thing about this is that the fields you are searching for should be either hardcoded OR driven by information from the form.  example below:

          Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From [Names] Where User_ID = " & txtUser_ID.Text.toString & "", myConnection)

This code above takes a field named txtUser_ID from the form and queries the db using its contents.  Also, be aware of the adding and removing of ' ' around text fields and numeric requirements of the database.  This can cause a problem when debugging.  

__________________________________________________________________________

Ok, the part where you are moving and retreiving the info from the database.

            .Parameters.Add(New OleDbParameter("@User_ID", OleDbType.Char, 10))
            .Parameters.Add(New OleDbParameter("@FName", OleDbType.Char, 25))
            .Parameters("@User_ID").Value = txtUser.Text    *****////Here is the problem /////
            .Parameters("@FName").Value = txtFname.Text  ******/// and here too ////
        End With

Here you are adding parameters to the command that retreives your information.  This is not recommended, possibly even wrong.  When you want to retreive the information when its one field you would extract = .ExecuteScalar  or many fields = .ExecuteReader or Insert and Updates = .ExecuteNonQuery.  Look below and see the fields I am retreiving, they are what you are looking for. I will setup a OleDb.OleDbDataReader and begin to read my database with my command I setup up above, see below

            Dim drUserID as OleDb.OleDbDataReader
            myConnection.Open()
            Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From [Names] Where User_ID=@User_ID"", myConnection)
            drUserID.ExecuteReader()
                 If drUserID.Read Then
                             txtUser_ID.text = drUserID("User_ID").toString
                             txtPW.text = drUserID("Password").toString
                             drUserID.close()
                 End If
             myConnection.Close()

__________________________________________________________________________

Now you have seen you code transformed in to a .NET enviorment.  Does this help?

gl,
Lucas



         


0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16529540
any good?

Lucas
0
 

Author Comment

by:masterat03
ID: 16531319
I was going to say I see you have it as a Private member. When I tried to put it within the search button I got an error say this '  'ExecuteReader' is not a member of 'System.Data.OleDb.OleDbDataReader'.

I made sure that at the top of my form I have imports System.data.Oledb

So Im assuming I have to call it like a method?...is that correct?
0
 

Author Comment

by:masterat03
ID: 16531484

Ok to keep things updated I did try the revision sample code like this
/////////////

Private Sub FillData()
        Dim myConnection As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")
        Dim drUserID As OleDb.OleDbDataReader
        myConnection.Open()
        Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From [Names] Where User_ID = " & txtUserID.Text.ToString & "", myConnection)
        drUserID.ExecuteReader()  *****////Giving me an error////
        If drUserID.Read Then
            txtUserID.Text = drUserID("User_ID").ToString
            txtFname.Text = drUserID("FName").ToString
            drUserID.Close()
        End If
        myConnection.Close()


    End Sub

/////////////////////////////


I tried calling the FillData() Private Method using a button...the idea of the button is that when the User inputs the UserID
the button will do the magic of putting the attributes to that Particular ID in a text Box.

But for some reason VB.net tells me that /////'ExecuteReader' is not a member of 'System.Data.OleDb.OleDbDataReader'.///

Even though in the code there is an object indicating ExecuteReader and like I said I also imported the System.data.Oledb
to my form

Is there something wrong that I'm doing...perhaps I need to import something else to use ExecuteReader()

Sorry but I'm such a noob to this ADO stuff lol
but I try :)


0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16531563
drUserID.ExecuteReader()  *****////Giving me an error////

Remove () on the last text

like this:

drUserID.ExecuteReader  *****////Giving me an error////

It is thinking it is a member of the DataReader.

try that.. everything looks ok.

let me know

gl,
Lucas
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16531581
Also, if you create in a Private Sub FillData()

You can have it called on button-click event.

or you can have this purely ran in your event.  Just double click button on form and it will bring you to the code page.  Just put all this code in there.  One thing though.  Make sure you put an IF around it to check for a NULL value in the textbox with the info you will be searching for.  Otherwise your Query will error...


If IsNullOrEmpty(txtUser_ID.Text) then  ///mess around with this until you get it...
Nothing
Else
You Code here
End If

Also try putting

Try
(Code)
Catch (ex as OleDb.OleDbException)
msgbox(ex.tostring)
End Try

this is very helpful way to debug.

-Lucas
0
 

Author Comment

by:masterat03
ID: 16534455
drUserID.ExecuteReader()  *****////Giving me an error////

Remove () on the last text

like this:

drUserID.ExecuteReader  *****////Giving me an error////

////////////////////

When I try to remove the () VB.net puts it back all the time.
0
 

Author Comment

by:masterat03
ID: 16534833
***Update again LOL ****

I just wanted to let you know that I think the way you are telling me to use the datareader object is wrong..
well because here is what I mean for example the code from before

Dim myConnection As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")
        Dim drUserID As OleDb.OleDbDataReader
        myConnection.Open()
        Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From [Names] Where User_ID = " & txtUserID.Text.ToString & "", myConnection)
        drUserID.ExecuteReader()   ///I think this is wrong///
        If drUserID.Read Then
            txtUserID.Text = drUserID("User_ID").ToString
            txtFname.Text = drUserID("FName").ToString
            drUserID.Close()
        End If
        myConnection.Close()
////////////////////////////////////

You see where it say drUserID.ExecuteReader()
I decided out of curiosity just to put the insertCmd which is an OLeDbCommand and attach it to this
insertCmd.ExecuteReader.

For some reason when I do that VB does recognize ExecuteReader
But If I decide to put drUserID.ExecuteReader it gives me an error.

I think personally the Executereader must work hand in hand with the OLEDBCommand object.

I could be wrong because I'm a noob, but I was just curious about the effect it did when I decided to change it.
Obviously when I ran the program nothing happened.

0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16534978
Friend strRepID As String
 'Retreive Rep Info
        Dim drRep As OleDb.OleDbDataReader
        Dim cmdRepFill As New OleDb.OleDbCommand("SELECT * From Reps_B2bgolf Where id = " & strRepID & " order by Name ", cnOleDb)
        Try
            <<<<<drRep = cmdRepFill.ExecuteReader>>>>  I see error here look at the bottom
            While drRep.Read
                strRepName = drRep("Name").ToString
                strRepNum = drRep("repnum").ToString
                strRepEmail = drRep("email").ToString
                strRepAuth = drRep("authority").ToString

            End While
        Catch ex As OleDb.OleDbException
            MessageBox.Show(ex.Message)
        Finally

End Try

Above is the exact code from my project...

Imports System.Xml
Imports System.Net
Imports System.Web
Imports System.IO
Imports System.Collections.ArrayList

here are my namespaces...

<<<change>>>
 drUserID.ExecuteReader()  
<<<to>>>>
drUserID = insertCmd.ExecuteReader
<<<end>>>

that should do it!
0
 

Author Comment

by:masterat03
ID: 16535327
***Update 2nd ****

Ok this is what I got so far I try to do as much as your example

Private Sub FillData()
        Dim myConnection As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")
        Dim drUserID As OleDbDataReader
        myConnection.Open()
        Dim insertCmd As New OleDbCommand("Select User_ID,FName From [Names] Where User_ID = " & txtUserID.Text.ToString & "", myConnection)
        drUserID = insertCmd.ExecuteReader  ////***Error ////


 Try
            While drUserID.Read
                txtUserID.Text = drUserID("User_ID").ToString
                txtFname.Text = drUserID("FName").ToString

            End While
        Catch ex As OleDbException
            MessageBox.Show(ex.Message)
        Finally

        End Try

        myConnection.Close()

    End Sub

/////Error Message : An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll ////

the example you gave me looks very self explanitory and im starting to get the point of this, but I'm still facing trouble with this stuff.

I always though this would work out so simple because I would think if the user puts in a value in a text box, the value would be search through the data base
and represent its attribute in the text box.

Kinda like datasets with dataAdapters....but I must be wrong lol.

I know we are so close to getting this to work and I do apologize for all the troubles that I have been causing since yesterday to make this work :(.

0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16535380
Change
Dim drUserID As OleDbDataReader
to
Dim drUserID As OleDb.OleDbDataReader

&

Dim insertCmd As New OleDbCommand
to
Dim insertCmd As New OleDb.OleDbCommand



Catch ex As OleDbException
MessageBox.Show(ex.Message)
to
Catch ex As OleDb.OleDbException
MsgBox(ex.toString)

I know it seems redundant but I am sure this will help.

What happens when you takes brackets off of the Table [Names], does it still give error?

Lucas
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16535398
Also, wrap it in an IF statement to make sure you are not passing a Null into the SQL query string.

And

txtUserID - Is this the name of your textbox on the design view>properties>name ?
0
 

Author Comment

by:masterat03
ID: 16535555

***Update 3rd ****

Dim myConnection As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")
        Dim drUserID As OleDb.OleDbDataReader
        myConnection.Open()
        Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From Names Where User_ID =" & txtUserID.Text.ToString & "", myConnection)
        drUserID = insertCmd.ExecuteReader  ///** Still breaks at this point////



Try


            While drUserID.Read
                txtUser.Text = drUserID("User_ID").ToString
                txtFname.Text = drUserID("FName").ToString

            End While
        Catch ex As OleDbException
            MsgBox(ex.Message)
        Finally


        End Try
       
        myConnection.Close()

///////////////////////


as for the properties txtUserID.Text is a textbox where the User inputs a value whether it is a number or a letter...It is not null because that is the only box
im using to pass a value to the SQL statement.

When I put a value in txtUserID I want its attribute to be presented in another textbox which is txtUser and txtFname that is the reason to use this :
//
 Try
            While drUserID.Read
                txtUserID.Text = drUserID("User_ID").ToString
                txtFname.Text = drUserID("FName").ToString

            End While

///


As for the brackets at the SQL statement I have tried it both ways with and without and VB tells me the error is at
drUserID = insertCmd.ExecuteReader  ///** Still breaks at this point////

////
lol Hell I triple check my DB file to make sure that the field names are correct just incase..you never know




0
 

Author Comment

by:masterat03
ID: 16535781
****///Update 4th////

Hey check this out I decided to put code
drUserID = insertCmd.ExecuteReader

inside the try-block statement like this

 Try
            drUserID = insertCmd.ExecuteReader

            While drUserID.Read
                txtUser.Text = drUserID("User_ID").ToString
                txtFname.Text = drUserID("FName").ToString

            End While
        Catch ex As OleDbException
            MsgBox(ex.Message)
        Finally


        End Try

//////////////////////

This actually runs the program and it doesnt crashes, but now when I decide to put in a value at the text box of txtUserID.text and try to display its attributes to
txtUser.text and txtFname.text

I get an exception message telling me /////****No value given for one or more required parameters////

I don't know why is this happening when im clearly putting a value at the textbox and then clicking on the button to show me the attributes of that value on to the
other textbox which is txtUser

0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16536039
OK, good, that is a SQL problem.  Now we are executing the Command.

Add a break to the ExecuteReader line for debugging when the code fires that event, it should stop and take you to the event in the code.  Once you are there, hover over the Datareader, drUserID and look at the SQL statement to make sure the values are showing up.  If you are not moving the txtUserID info correctly you might be accidently checking for a NULL value.

Also, add this

MsgBox(txtUserID.Text.ToString) to check for whats in here when event fires.

add it right before the Try.  What happens when you do this?

Lucas
0
 

Author Comment

by:masterat03
ID: 16536237
***//// Update 5th LOL ///
it gets crazier I tell you.

Ok I added the breakpoint...before I did though let me tell you this.

When I put let say a value to the txtUserID.text box and I press the button to do a search in order to display the attributes to the other 2 textboxes (txtUser, txtFname)

It gave me the same error /////****No value given for one or more required parameters////
BUT it then also show me in a messagebox the value I inserted in the textbox which was "C"..I chose to put C
because I know its a value in the Database and I triple checked it...I could also put numbers like "12" etc because I know for sure these values are in the database.


Now to get to the breakpoint part.

I put a breakpoint at "drUserID = insertCmd.ExecuteReader () " and this is what VB tells me

Name                             Value                               Type
drUserID                        Nothing                             System.Data.Oledb.OledbDataReader
txtFname.text                 '''''                                    String
txtUser.Text                   '''''                                     String


....so pretty much from what I can see either the textbox that I putting the value in is not being read by the SQL statement
or it can be something else?

0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16536344
When you break at the breakpoint, what does it say when you hover over the insertCmd.

Can you type in what it says?

                                           Dim drUserID As OleDb.OleDbDataReader
                                           myConnection.Open()
    Hover Over insertCmd here >>> Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From Names Where                                       User_ID " &  txtUserID.Text.ToString & "", myConnection)
DEBUG BREAK HERE ***        drUserID = insertCmd.ExecuteReader  

0
 

Author Comment

by:masterat03
ID: 16536380

ok in the new line that i put the breakpoint

Hover Over insertCmd here >>> Dim insertCmd As New OleDb.OleDbCommand("Select User_ID,FName From Names Where                                       User_ID " &  txtUserID.Text.ToString & "", myConnection)

it say
insertCmd=Nothing
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16536389
make sure the line doesnt have a breakpoint on it.  just need one at the next line below
0
 

Author Comment

by:masterat03
ID: 16536468


Ok I did it again I put the breaking point at
drUserId = insertCmd.ExecuteReader()


when I hover over Dim insertCmd As New OleDb.OleDbCommand("Select User_ID, FName From [Names] Where User_ID= " & txtUserID.Text.ToString & "", myConnection)

it says that insertCmd = {System.Data.Oledb.OledbCommand}

***Sorry for all your trouble :( ...being a noob is horrible I tell you lol

0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16536503
ok sry, wasnt explicit enough

do you see a + while you hover, hover over that alos, then go until you see your SQL Statement  IT should expand like a menu.  Look for something call ed CommandText

Also,  is USER_ID a number field in database?
0
 

Author Comment

by:masterat03
ID: 16536686


ok this is what I have so far

 Dim UserID = txtUserID.Text
        Dim myConnection As New OleDb.OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb;")
        Dim drUserID As OleDb.OleDbDataReader
        myConnection.Open()
        Dim insertCmd As New OleDb.OleDbCommand("Select User_ID, FName From [Names] Where User_ID= " & txtUserID.Text.ToString & "", myConnection)


 Try
            drUserID = insertCmd.ExecuteReader()  ///***breakpoint is inserted here///

            While drUserID.Read
                txtUser.Text = drUserID("User_ID").ToString
                txtFname.Text = drUserID("FName").ToString

            End While
        Catch ex As OleDbException
            MsgBox(ex.Message)
            MsgBox(txtUserID.Text.ToString)

        Finally


        End Try

 myConnection.Close()

////

when I hover over insertcmd it gives me the same output as I wrote above.
There is no plus ( + ) sign that appears I look at the lower left hand sign and I dont see
no plus sign either.

Now when I remove the breakpoint from
 drUserID = insertCmd.ExecuteReader()  

and put it in
 Dim insertCmd As New OleDb.OleDbCommand("Select User_ID, FName From [Names] Where User_ID= " & txtUserID.Text.ToString & "", myConnection)

I see a  + sign at the lower left hand corner and its align with (" myconnection")
, but I dont see CommandText.

I see alot of other things like timeout, Connectionstring,container,database,etc,etc

I hope this helps out since at this point im soooo lost lol
but trying my best to help out the situation


0
 

Author Comment

by:masterat03
ID: 16536710
**Opps almost forgot about
the question you ask if User_ID can take numbers
the answer is Yes.

I usually use letters, but I do have numbers they are translated in Access as Text
and as for VB it really doesnt matter because I'm not doing any calculation with the numbers its self
so they are pretty much handle as strings
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16536788
Do you have Access?
0
 

Author Comment

by:masterat03
ID: 16536800
Of course I do look at the title at the top of this page lol
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16536831
ok, build a SQL statement in a query that would match what you think you are getting in the SQL statement UserID area.

just type

Select User_ID, FName From [Names] Where User_ID= 'C'

see what happens...this can help you bug your SQL statement.  Sounds like your command is hitting your database but it doesnt like your WHERE clause.
0
 

Author Comment

by:masterat03
ID: 16536874
Ok I did it and it showed me
the Value and the attributes


When I did

SELECT User_ID, Fname
FROM [Names]
WHERE User_ID='C';

It gave me the output I desired to have
0
 
LVL 3

Accepted Solution

by:
Kudzullc earned 2000 total points
ID: 16536978
Select User_ID, FName From [Names] Where User_ID= '" & txtUserID.Text.ToString & "'"

add ' ' around the txtbox.tostring     opened up it looks like     ' "  & txtUserID.Text.ToString & " ' " but with no spaces then try using the button
0
 

Author Comment

by:masterat03
ID: 16537050
LMAO
LOL
sorry I can't stop laughing because to think that just because ' "  & txtUserID.Text.ToString & " ' "
of the way the ' " are set up it was not able to pick up the value set on the text box.

Dam lol I'm sure you are probably saying to yourself THANKGOD Lol Finally it worked

Well I have to say thankyou soooooo much for helping me out and I'm sorry for being a pest of a noob

Like I said it definetly works like a charm I can pass values to it from above and it gives me the attributes on the other 2 textboxes

I was going to say is there anybook you recommend I ve been having soooooooooo much trouble when it comes to SQL using VB.net

Also I have to say I like the way you introduce the idea of using connectivity to the database it cuts down alot of the work I did to just
1 line of code

You have really help me Kudzullc Thankyou for the help and I'm so sorry for all the troubles I might of caused you
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16537120
LOL!!!  Great!

Its going to always be something small...

try this one

http://www.amazon.com/gp/product/0735621640/sr=8-1/qid=1145991899/ref=pd_bbs_1/104-6437949-5976766?%5Fencoding=UTF8

and good luck!
0
 

Author Comment

by:masterat03
ID: 16537192

Yeah I know its always the little things that troubles us all the time.

Again thankyou so much and thankyou for helping me :)

also I will look into the book and see if I can learn more and more on ADO.

Take care
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16537239
Thanks for the Upgrade in points!

gl,
Lucas
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question