PC Review


Reply
Thread Tools Rate Thread

adding data to SQL from form textbox, a variable

 
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      15th Nov 2004
Hi all,
I know this is easy, just can't seem to get it. I have a windows form, and
a text box, with a value already in it. I need to add that value to a table.
It's just one value, so the entire row doesn't get filled. I have a
connection and all that stuff.

Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPlaceBet.Click
' Dim Myds As Footbet.DStable
' txbxCPwage.DataBindings.Add("txbxCPwage", Myds, "TableID.Pass")

Just looking for the code to pass this value to the DS.

TIA!
Rudy

 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      16th Nov 2004
Rudy,

I do not understand you, therefore I give you 2 answers, if you want to add
it to the databaset table, than you have to create an SQL insert command and
than use an SQLcommand.nonquery to update your database, that is all.

http://msdn.microsoft.com/library/de...QueryTopic.asp

When you want to add it to an item in a row in a datatable in a dataset than
it can be
ds.tables("thetable").rows(therownumber)("theItem") = "xxxx"

I hope this helps?

Cor

"Rudy" <(E-Mail Removed)>
> Hi all,
> I know this is easy, just can't seem to get it. I have a windows form,
> and
> a text box, with a value already in it. I need to add that value to a
> table.
> It's just one value, so the entire row doesn't get filled. I have a
> connection and all that stuff.
>
> Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnPlaceBet.Click
> ' Dim Myds As Footbet.DStable
> ' txbxCPwage.DataBindings.Add("txbxCPwage", Myds, "TableID.Pass")
>
> Just looking for the code to pass this value to the DS.
>
> TIA!
> Rudy
>



 
Reply With Quote
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      16th Nov 2004
Hi Cor,
Thank you for your input. Let me try to explain a little bit better. I have
an answer to a formula that will show up in textbox1. I have 4 textboxs with
the same situation, except the formula is diffrent for each textbox,
therefore, four diffrent answers. In my table i have a column name textbox1,
2, 3, and 4, to match the information to the form. Anyone of the values in
the textbox need to be placed in the table, just 1 or 2 or 3 or all 4 at any
time. When the ENTER button click_event is fired, it needs to take the
values, put them in the approiate coulmns. I'm using SQL by the way for
this. So I'm not sure if I can specify which row it will go into, because it
really doesn't matter. the info will just keep adding to the next row. I
guess the row number would relate to how many times the ENTER click event is
fired. first click, row 1, second click, row 2. In addition, to make things
more interesting, I need to be able to have 5 client computers that has this
setup, going to one SQL server. The number of clicks would actually be total
number from all five clients. Right now I have column in the table to keep
track of which client is enter the values. But I thought about just make
duplicate tables, for the diffrent clients, not sure which would be better.
The max clients I may have is 100. I hope this make sense. Sorry for
rambling on.
Rudy


"Cor Ligthert" wrote:

> Rudy,
>
> I do not understand you, therefore I give you 2 answers, if you want to add
> it to the databaset table, than you have to create an SQL insert command and
> than use an SQLcommand.nonquery to update your database, that is all.
>
> http://msdn.microsoft.com/library/de...QueryTopic.asp
>
> When you want to add it to an item in a row in a datatable in a dataset than
> it can be
> ds.tables("thetable").rows(therownumber)("theItem") = "xxxx"
>
> I hope this helps?
>
> Cor
>
> "Rudy" <(E-Mail Removed)>
> > Hi all,
> > I know this is easy, just can't seem to get it. I have a windows form,
> > and
> > a text box, with a value already in it. I need to add that value to a
> > table.
> > It's just one value, so the entire row doesn't get filled. I have a
> > connection and all that stuff.
> >
> > Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles btnPlaceBet.Click
> > ' Dim Myds As Footbet.DStable
> > ' txbxCPwage.DataBindings.Add("txbxCPwage", Myds, "TableID.Pass")
> >
> > Just looking for the code to pass this value to the DS.
> >
> > TIA!
> > Rudy
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?RHVQb250?=
Guest
Posts: n/a
 
      16th Nov 2004
Hello Rudy,

Your right this is actually easy but a little bit of code writing will be
involved.

First, Are you writing these values to existing records or are you creating
a new record based on these formulas.. Its not a big deal if which one your
doing or if your doing both..

You will need the following

SqlConnection
SqlDataAdapter
SqlCommandBuilder
DataSet
DataRow

Exp..

Dim objSqlConn As SqlConnection
Dim objSqlDa As SqlDataAdapter
Dim objSqlCmdB As SqlCommandBuilder
Dim objSqlDs as New DataSet
Dim objSqlRow as DataRow

objSqlConn = New SqlConnection(String of connection)
objSqlConn.Open

Dim strSqlTxt As String = ("Your query statement, usually a SELECT type")
**** Now this can be written in a manner as to return existing records or
where a field = Null so you nothing is returned, but you have a base for
adding new records.****

objSqlDa = New SqlDataAdapter("strSqlTxt", objSqlConn)
objSqlCmdB = New SqlCommandBuilder(objSqlDa)
objSqlDa.Fill(objSqlDs)

*** This next bit of code is for adding a record and filling the values ****

objSqlRow = objSqlDs.Tables(0).NewRow

With objSqlRow
.Item("TextBox1") = TextBox1.Text
.Item("TextBox2") = TextBox2.Text
Ect ect ect

End with

objSqlDs.Tables(0).Rows.Add(objSqlRow)
objSqlDa.Update(objSqlDs)

****Now if you have a query that is searching for an existing record you can
do the samw but with out adding a new record ****


objSqlRow = objSqlDs.Tables(0).Rows(0)

With objSqlRow

.Item("TextBox1") = TextBox1.Text
Ect, ect,ect ect..

End With

objSqlDa.Update(objSqlDs)



Well you might get the idea, if you have any questions feel free to ask...

Best regards,




"Rudy" wrote:

> Hi Cor,
> Thank you for your input. Let me try to explain a little bit better. I have
> an answer to a formula that will show up in textbox1. I have 4 textboxs with
> the same situation, except the formula is diffrent for each textbox,
> therefore, four diffrent answers. In my table i have a column name textbox1,
> 2, 3, and 4, to match the information to the form. Anyone of the values in
> the textbox need to be placed in the table, just 1 or 2 or 3 or all 4 at any
> time. When the ENTER button click_event is fired, it needs to take the
> values, put them in the approiate coulmns. I'm using SQL by the way for
> this. So I'm not sure if I can specify which row it will go into, because it
> really doesn't matter. the info will just keep adding to the next row. I
> guess the row number would relate to how many times the ENTER click event is
> fired. first click, row 1, second click, row 2. In addition, to make things
> more interesting, I need to be able to have 5 client computers that has this
> setup, going to one SQL server. The number of clicks would actually be total
> number from all five clients. Right now I have column in the table to keep
> track of which client is enter the values. But I thought about just make
> duplicate tables, for the diffrent clients, not sure which would be better.
> The max clients I may have is 100. I hope this make sense. Sorry for
> rambling on.
> Rudy
>
>
> "Cor Ligthert" wrote:
>
> > Rudy,
> >
> > I do not understand you, therefore I give you 2 answers, if you want to add
> > it to the databaset table, than you have to create an SQL insert command and
> > than use an SQLcommand.nonquery to update your database, that is all.
> >
> > http://msdn.microsoft.com/library/de...QueryTopic.asp
> >
> > When you want to add it to an item in a row in a datatable in a dataset than
> > it can be
> > ds.tables("thetable").rows(therownumber)("theItem") = "xxxx"
> >
> > I hope this helps?
> >
> > Cor
> >
> > "Rudy" <(E-Mail Removed)>
> > > Hi all,
> > > I know this is easy, just can't seem to get it. I have a windows form,
> > > and
> > > a text box, with a value already in it. I need to add that value to a
> > > table.
> > > It's just one value, so the entire row doesn't get filled. I have a
> > > connection and all that stuff.
> > >
> > > Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles btnPlaceBet.Click
> > > ' Dim Myds As Footbet.DStable
> > > ' txbxCPwage.DataBindings.Add("txbxCPwage", Myds, "TableID.Pass")
> > >
> > > Just looking for the code to pass this value to the DS.
> > >
> > > TIA!
> > > Rudy
> > >

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      16th Nov 2004
Thank You DuPont, I will try this tonight and let you know.

Rudy

"DuPont" wrote:

> Hello Rudy,
>
> Your right this is actually easy but a little bit of code writing will be
> involved.
>
> First, Are you writing these values to existing records or are you creating
> a new record based on these formulas.. Its not a big deal if which one your
> doing or if your doing both..
>
> You will need the following
>
> SqlConnection
> SqlDataAdapter
> SqlCommandBuilder
> DataSet
> DataRow
>
> Exp..
>
> Dim objSqlConn As SqlConnection
> Dim objSqlDa As SqlDataAdapter
> Dim objSqlCmdB As SqlCommandBuilder
> Dim objSqlDs as New DataSet
> Dim objSqlRow as DataRow
>
> objSqlConn = New SqlConnection(String of connection)
> objSqlConn.Open
>
> Dim strSqlTxt As String = ("Your query statement, usually a SELECT type")
> **** Now this can be written in a manner as to return existing records or
> where a field = Null so you nothing is returned, but you have a base for
> adding new records.****
>
> objSqlDa = New SqlDataAdapter("strSqlTxt", objSqlConn)
> objSqlCmdB = New SqlCommandBuilder(objSqlDa)
> objSqlDa.Fill(objSqlDs)
>
> *** This next bit of code is for adding a record and filling the values ****
>
> objSqlRow = objSqlDs.Tables(0).NewRow
>
> With objSqlRow
> .Item("TextBox1") = TextBox1.Text
> .Item("TextBox2") = TextBox2.Text
> Ect ect ect
>
> End with
>
> objSqlDs.Tables(0).Rows.Add(objSqlRow)
> objSqlDa.Update(objSqlDs)
>
> ****Now if you have a query that is searching for an existing record you can
> do the samw but with out adding a new record ****
>
>
> objSqlRow = objSqlDs.Tables(0).Rows(0)
>
> With objSqlRow
>
> .Item("TextBox1") = TextBox1.Text
> Ect, ect,ect ect..
>
> End With
>
> objSqlDa.Update(objSqlDs)
>
>
>
> Well you might get the idea, if you have any questions feel free to ask...
>
> Best regards,
>
>
>
>
> "Rudy" wrote:
>
> > Hi Cor,
> > Thank you for your input. Let me try to explain a little bit better. I have
> > an answer to a formula that will show up in textbox1. I have 4 textboxs with
> > the same situation, except the formula is diffrent for each textbox,
> > therefore, four diffrent answers. In my table i have a column name textbox1,
> > 2, 3, and 4, to match the information to the form. Anyone of the values in
> > the textbox need to be placed in the table, just 1 or 2 or 3 or all 4 at any
> > time. When the ENTER button click_event is fired, it needs to take the
> > values, put them in the approiate coulmns. I'm using SQL by the way for
> > this. So I'm not sure if I can specify which row it will go into, because it
> > really doesn't matter. the info will just keep adding to the next row. I
> > guess the row number would relate to how many times the ENTER click event is
> > fired. first click, row 1, second click, row 2. In addition, to make things
> > more interesting, I need to be able to have 5 client computers that has this
> > setup, going to one SQL server. The number of clicks would actually be total
> > number from all five clients. Right now I have column in the table to keep
> > track of which client is enter the values. But I thought about just make
> > duplicate tables, for the diffrent clients, not sure which would be better.
> > The max clients I may have is 100. I hope this make sense. Sorry for
> > rambling on.
> > Rudy
> >
> >
> > "Cor Ligthert" wrote:
> >
> > > Rudy,
> > >
> > > I do not understand you, therefore I give you 2 answers, if you want to add
> > > it to the databaset table, than you have to create an SQL insert command and
> > > than use an SQLcommand.nonquery to update your database, that is all.
> > >
> > > http://msdn.microsoft.com/library/de...QueryTopic.asp
> > >
> > > When you want to add it to an item in a row in a datatable in a dataset than
> > > it can be
> > > ds.tables("thetable").rows(therownumber)("theItem") = "xxxx"
> > >
> > > I hope this helps?
> > >
> > > Cor
> > >
> > > "Rudy" <(E-Mail Removed)>
> > > > Hi all,
> > > > I know this is easy, just can't seem to get it. I have a windows form,
> > > > and
> > > > a text box, with a value already in it. I need to add that value to a
> > > > table.
> > > > It's just one value, so the entire row doesn't get filled. I have a
> > > > connection and all that stuff.
> > > >
> > > > Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
> > > > System.EventArgs) Handles btnPlaceBet.Click
> > > > ' Dim Myds As Footbet.DStable
> > > > ' txbxCPwage.DataBindings.Add("txbxCPwage", Myds, "TableID.Pass")
> > > >
> > > > Just looking for the code to pass this value to the DS.
> > > >
> > > > TIA!
> > > > Rudy
> > > >
> > >
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?UnVkeQ==?=
Guest
Posts: n/a
 
      17th Nov 2004
Hi DuPont,


I am getting the following error - Object reference not set to an instance
of an object
This gets stopped at the objSqlRow = objSqlDs.tables(0).NewRow

I wrote the code out like you suggested, i didn't use...

> objSqlDa = New SqlDataAdapter("strSqlTxt", objSqlConn)
> objSqlCmdB = New SqlCommandBuilder(objSqlDa)
> objSqlDa.Fill(objSqlDs)

Then I did try it, but got a Null Value error.

I don't understand why I need a SELECT statement, when I'm doing an update.
I guess I'm a little confused.

Thanks for your patcience!

Rudy

"DuPont" wrote:

> Hello Rudy,
>
> Your right this is actually easy but a little bit of code writing will be
> involved.
>
> First, Are you writing these values to existing records or are you creating
> a new record based on these formulas.. Its not a big deal if which one your
> doing or if your doing both..
>
> You will need the following
>
> SqlConnection
> SqlDataAdapter
> SqlCommandBuilder
> DataSet
> DataRow
>
> Exp..
>
> Dim objSqlConn As SqlConnection
> Dim objSqlDa As SqlDataAdapter
> Dim objSqlCmdB As SqlCommandBuilder
> Dim objSqlDs as New DataSet
> Dim objSqlRow as DataRow
>
> objSqlConn = New SqlConnection(String of connection)
> objSqlConn.Open
>
> Dim strSqlTxt As String = ("Your query statement, usually a SELECT type")
> **** Now this can be written in a manner as to return existing records or
> where a field = Null so you nothing is returned, but you have a base for
> adding new records.****
>
> objSqlDa = New SqlDataAdapter("strSqlTxt", objSqlConn)
> objSqlCmdB = New SqlCommandBuilder(objSqlDa)
> objSqlDa.Fill(objSqlDs)
>
> *** This next bit of code is for adding a record and filling the values ****
>
> objSqlRow = objSqlDs.Tables(0).NewRow
>
> With objSqlRow
> .Item("TextBox1") = TextBox1.Text
> .Item("TextBox2") = TextBox2.Text
> Ect ect ect
>
> End with
>
> objSqlDs.Tables(0).Rows.Add(objSqlRow)
> objSqlDa.Update(objSqlDs)
>
> ****Now if you have a query that is searching for an existing record you can
> do the samw but with out adding a new record ****
>
>
> objSqlRow = objSqlDs.Tables(0).Rows(0)
>
> With objSqlRow
>
> .Item("TextBox1") = TextBox1.Text
> Ect, ect,ect ect..
>
> End With
>
> objSqlDa.Update(objSqlDs)
>
>
>
> Well you might get the idea, if you have any questions feel free to ask...
>
> Best regards,
>
>
>
>
> "Rudy" wrote:
>
> > Hi Cor,
> > Thank you for your input. Let me try to explain a little bit better. I have
> > an answer to a formula that will show up in textbox1. I have 4 textboxs with
> > the same situation, except the formula is diffrent for each textbox,
> > therefore, four diffrent answers. In my table i have a column name textbox1,
> > 2, 3, and 4, to match the information to the form. Anyone of the values in
> > the textbox need to be placed in the table, just 1 or 2 or 3 or all 4 at any
> > time. When the ENTER button click_event is fired, it needs to take the
> > values, put them in the approiate coulmns. I'm using SQL by the way for
> > this. So I'm not sure if I can specify which row it will go into, because it
> > really doesn't matter. the info will just keep adding to the next row. I
> > guess the row number would relate to how many times the ENTER click event is
> > fired. first click, row 1, second click, row 2. In addition, to make things
> > more interesting, I need to be able to have 5 client computers that has this
> > setup, going to one SQL server. The number of clicks would actually be total
> > number from all five clients. Right now I have column in the table to keep
> > track of which client is enter the values. But I thought about just make
> > duplicate tables, for the diffrent clients, not sure which would be better.
> > The max clients I may have is 100. I hope this make sense. Sorry for
> > rambling on.
> > Rudy
> >
> >
> > "Cor Ligthert" wrote:
> >
> > > Rudy,
> > >
> > > I do not understand you, therefore I give you 2 answers, if you want to add
> > > it to the databaset table, than you have to create an SQL insert command and
> > > than use an SQLcommand.nonquery to update your database, that is all.
> > >
> > > http://msdn.microsoft.com/library/de...QueryTopic.asp
> > >
> > > When you want to add it to an item in a row in a datatable in a dataset than
> > > it can be
> > > ds.tables("thetable").rows(therownumber)("theItem") = "xxxx"
> > >
> > > I hope this helps?
> > >
> > > Cor
> > >
> > > "Rudy" <(E-Mail Removed)>
> > > > Hi all,
> > > > I know this is easy, just can't seem to get it. I have a windows form,
> > > > and
> > > > a text box, with a value already in it. I need to add that value to a
> > > > table.
> > > > It's just one value, so the entire row doesn't get filled. I have a
> > > > connection and all that stuff.
> > > >
> > > > Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
> > > > System.EventArgs) Handles btnPlaceBet.Click
> > > > ' Dim Myds As Footbet.DStable
> > > > ' txbxCPwage.DataBindings.Add("txbxCPwage", Myds, "TableID.Pass")
> > > >
> > > > Just looking for the code to pass this value to the DS.
> > > >
> > > > TIA!
> > > > Rudy
> > > >
> > >
> > >
> > >

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      17th Nov 2004
Rudy,

A fill is not an update, that is reading the data into the datast
A update is an update.

\\\something like this is a complete reading and updating,
\\\however there is needed a lot of checking etc with this.
\\\and therefore this is almost the most simple format.
dim ds as new datataset
dim SQLtxt as string = Select * from mytable"
Da = New SqlDataAdapter("SqlTxt", Conn)
Da.Fill(Ds)
Cmd = New SqlCommandBuilder(Da)
ds.tables(0).rows(0).item(1)="SeconditemFirstrowChangedFromTextbox"
da.update(ds)
///

I hope that this helps?

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
form with variable/flexible input textbox David Chang Microsoft Outlook VBA Programming 2 5th Dec 2006 02:13 PM
Adding textbox to form with VBA =?Utf-8?B?QmlsbA==?= Microsoft Access Form Coding 4 19th Oct 2004 04:44 PM
having trouble adding more than one textbox to a form using vba GregJG Microsoft Excel Misc 5 11th Jul 2004 06:48 PM
Passing Variable String from Form to a Report Textbox Jonathan Mulder Microsoft Access Reports 3 24th Feb 2004 05:04 AM
Adding up values in a textbox on a form Rhema Microsoft Excel Misc 1 7th Nov 2003 03:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:51 AM.