Accessing SQL dataset value from button

  • Thread starter Thread starter nomail.thanks
  • Start date Start date
N

nomail.thanks

I apologize for the question in advance. I have lots of experience
with lots of other languages, but now I'm trying to accomplish
something with VB.NET Express. My experience with VB.NET express is
less than a week. I've gone through what appear to be the relevant
tutorials that came with the product, consulted the two reference books
I have, explored the source code that is being generated by my project,
and played around trying various things for about a day and a half now,
and since I'm sure there is a simple solution to what I am trying to
accomplish, I decided the time has come to just ask the experts.

I've built my SQL database, and VB.NET is connecting to it just fine,
displaying the value of each row as details. The form which is
displaying the data also has a couple of buttons, and when I click on a
button, I want to pass the values being displayed in the form's text
fields to an external subroutine. The call to the subroutine is going
just fine, and I can pass constants to it, but I'm having trouble
figuring out how to get the data values I want out of the text fields.

Let's say my database is called MyDatabase, the table I'm accessing is
MyTable1, and the column I want to pass is Name. How do I get the
currently-displayed value of "Name" into a variable I can pass to a
subroutine? Or, even better, what is the variable that already
contains this value in VB.NET Express? Thanks in advance to anyone who
can provide a solution.
 
Okay, by my count, seven people who knew the answer have already read
this question and deemed it too simple to respond to. After trying all
kinds of Me.MyTable1.TableAdapter.Getdata.Namecolumn variations, I
finally saw that a simple NameTextBox.Text had the value I wanted.
Thanks anyway; kudos to me.
 
Kudos to you!! :-)
Did you ever stop to think that maybe, those seven people that you say read
the post and knew the answer, may not have?
I read lots of posts in newsgroups but, that doesn't mean I know the answers
to every one of them. And , after re-reading your original post, there was
nothing there that would have helped anyone know that a simple
"NameTextBox.Text" had the value you were looking for. You didn't post any
of your code to help others help you. Not knowing what you had done so far,
(code wise) makes it hard to offer constructive suggestions or solutions.
Don't give up on asking for help when you need it. But, try to post some of
the code you are working with so if there is a simple solution, it might be
easier for others to help you find.
james
 
Hey, I appreciate the feedback. The "seven people" was obviously a
joke, but I figure pretty much everyone on this newsgroup knows more
than I do, and thought somebody who knew the answer had probably moved
on to a more challenging problem without responding. From what you're
saying, maybe I was wrong.

As I say, I'm new to VB, and actually new to IDEs as well. Since the
pieces are all over the place, I didn't think posting my code would
help. The code I have in my View Code window just has the Form1 code
-- 3 private subroutines, one for Form1_Load, one for
TableBindingSaveNavigator_Click, and one for my Button1_Click. My
solution is there now in Button1_Click, but I hardly think that posting
what was there before would have been any more help than the
description of the problem I posted initially. Maybe I'm wrong about
that too.

Anyway, I do appreciate the feedback. Hopefully, the next time I need
help, I'll know enough to have a better idea of how to ask for it.
 
Nomail,

The biggest problem using Net is learn not to use your old methods anymore.

The most simple way to access data using Net is using the designers. They
are not often sufficient, however they have reached a stadium that it is
good to do.

Try this one, and know that all the code that is generated is viewable for
you by clicking in the solution explorer "show all files"

http://www.vb-tips.com/default.aspx?ID=1139f14a-c236-4ad7-8882-b1ed16424252

I hope this helps,

Cor
 
Keep in mind, that although this is a 24 hours newsgroup, is it in the
weekend less active than during working days.

As well is in my opinion your text by trying to describe everything not very
clear what you really want..

How can I put the value 1 in whatever textbox would have given you many of
these kind of answers.

MyTextbox.Text = "1"

or asking "how can I get the Text of a textbox in a string" would have been

dim myfield as string = myTextBox.Text

Now we probably all had the idea that it was an adonet question.

I hope this helps,

Cor
 
Back
Top