473,471 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to save from textbox

anyone know how to save record that is encoded from a textbox back to
sql server 2000? i know how to display a record from sql server to
textbox but don't know how to save the changes i made.

thanks in advance
Nov 20 '05 #1
2 1294
Hi,

One way would be to use DataTable as datasource, load data there, bind
textbox to it and after editing call DataAdapter.Update method.
Anyway, how are you doing it now?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"jaYPee" <hi******@yahoo.com> wrote in message
news:9q********************************@4ax.com...
anyone know how to save record that is encoded from a textbox back to
sql server 2000? i know how to display a record from sql server to
textbox but don't know how to save the changes i made.

thanks in advance

Nov 20 '05 #2
Hi there, I have the exact same frustration except with webforms....

http://www.15seconds.com/issue/030604.htm

I found this hope it helps a bit! Also download the visual basic .net
resource kit it has some examples exactly for what your talking about as
well.

Private Sub UpdateProduct()

' This sub is used to update and existing record with values

' from the form.

Dim cnSQL As SqlConnection

Dim cmSQL As SqlCommand

Dim strSQL As String

Dim intRowsAffected As Integer

' Validate form values.

If Not IsValidForm() Then

Exit Sub

End If

Try

' Build update statement to update product table with data

' on form.

strSQL = "UPDATE Products SET" & _

" ProductName = " & PrepareStr(txtProductName.Text) & _

" ,QuantityPerUnit = " & PrepareStr(txtQtyPerUnit.Text) & _

" ,UnitPrice = " & txtUnitPrice.Text & _

" ,UnitsInStock = " & txtUnitsInStock.Text & _

" ,UnitsOnOrder = " & txtUnitsOnOrder.Text & _

" ,ReorderLevel = " & txtReorderLevel.Text & _

" ,SupplierID = " & CType(cbSuppliers.Items(cbSuppliers.SelectedIndex) ,
ListItem).ID & _

" ,CategoryID = " & CType(cbCategories.Items(cbCategories.SelectedInde x),
ListItem).ID & _

" ,Discontinued = " & CType(IIf(chkDiscontinued.Checked, "1", "0"), String)
& " " & _

"WHERE ProductID = " & CInt(txtProductID.Text)

cnSQL = New SqlConnection(ConnectionString)

cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)

intRowsAffected = cmSQL.ExecuteNonQuery()

If intRowsAffected <> 1 Then

MsgBox("Update Failed.", MsgBoxStyle.Critical, "Update")

End If

' Close and Clean up objects

cnSQL.Close()

cmSQL.Dispose()

cnSQL.Dispose()

Catch e As SqlException

MsgBox(e.Message, MsgBoxStyle.Critical, "SQL Error")

Catch e As Exception

MsgBox(e.Message, MsgBoxStyle.Critical, "General Error")

End Try

End Sub

Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRefresh.Click

PopulateCategoryCombo()

PopulateSupplierCombo()

PopulateProductList()

End Sub

"jaYPee" <hi******@yahoo.com> wrote in message
news:9q********************************@4ax.com...
anyone know how to save record that is encoded from a textbox back to
sql server 2000? i know how to display a record from sql server to
textbox but don't know how to save the changes i made.

thanks in advance

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alvo von Cossel I | last post by:
hi, i have a textbox in a form. when you press a Save button, a savefiledialog appears. creating ther file works but everytime you click save, the dialog appears. how do i make the dialog appear...
2
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
2
by: crjunk | last post by:
I'm trying to write a piece of code that will programatically save a record automatically without me having to add a new ' Row.Item("ADD1") = txtAdd1.Text.Trim.ToUpper ' type command each time I...
6
by: kurt | last post by:
Hi all, I have something that has me stumped. I have a webform that has several text boxes. Each of these boxes has the textchanged set so when the user enters text and leaves the textbox, it...
2
by: jason | last post by:
hello. i am just trying to save a TextBox.Text value to a database, but strangely, when the value is changed on the web form, the changes are not recognized in the event where i try to save the...
1
by: David | last post by:
Hi, I have a continuous form with 'x' amount of records. 1 field on each record is a number, of which I have a field at the top of the form which just shows the running sum. If I enter a new...
2
by: toddw607 | last post by:
Hi all! I am attempting to bring an SQL Server table into ASP.NET using the datagrid . I have set all cells to be a text box by which the user can just click on and edit the cell. I have a...
1
by: =?Utf-8?B?U2hhdw==?= | last post by:
I have a small GridView about max 10 rows and few columns. The columns are simple just a checkbox and a textbox and a bound name. The users don’t want to click “edit” button to edit and...
2
by: KC-Mass | last post by:
I have a form that is used to ID and then load Excel files into Access. I use labels on the form to record which file was last loaded. That was accomplished with a simple lblFileLoaded =...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.