473,804 Members | 3,941 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code to update the table

Please excuse my ignorance, but I am trying to teach myself .Net
without a lot of help. At this point I have created a page with a few
text boxes and combo boxes that I am using as an example.

The page displays nicely with the Requestor, DivMgr, ChgType,
Description fields.

What I would like to do at this point is create a Save button (at
bottom ref: Button1_Click) that, when clicked, inserts the data to the
table.

Can a .Net guru help with this one?
Thanks for the help in advance.

'************** *************** *************** *************** *
Imports System.Data.Sql Client

Public Class WebForm1
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Dim configurationAp pSettings As
System.Configur ation.AppSettin gsReader = New
System.Configur ation.AppSettin gsReader
Me.conn = New System.Data.Sql Client.SqlConne ction
'
'conn
'
Me.conn.Connect ionString =
CType(configura tionAppSettings .GetValue("conn .ConnectionStri ng",
GetType(System. String)), String)

End Sub
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
Protected WithEvents conn As System.Data.Sql Client.SqlConne ction
Protected WithEvents ddlRequestor As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents ddlDivMgr As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Label2 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label3 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label4 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label5 As System.Web.UI.W ebControls.Labe l
Protected WithEvents tbxDescription As
System.Web.UI.W ebControls.Text Box
Protected WithEvents tbxChangeName As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label6 As System.Web.UI.W ebControls.Labe l
Protected WithEvents ddlChangeType As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Dim query As String
Dim ds As New DataSet
query = "select names from requestor order by names"
Dim da As New SqlDataAdapter( query, conn)
da.Fill(ds, "Requestor" )
ddlRequestor.Da taSource = ds
ddlRequestor.Da taMember = "Requestor"
ddlRequestor.Da taTextField = "names"
ddlRequestor.Da taBind()

query = "select DivMgr from DivMgr order by DivMgr"
Dim daDivMgr As New SqlDataAdapter( query, conn)
daDivMgr.Fill(d s, "DivMgr")
ddlDivMgr.DataS ource = ds
ddlDivMgr.DataM ember = "DivMgr"
ddlDivMgr.DataT extField = "DivMgr"
ddlDivMgr.DataB ind()

query = "select Type from ChgType order by Type"
Dim daChangeType As New SqlDataAdapter( query, conn)
daChangeType.Fi ll(ds, "ChgType")
ddlChangeType.D ataSource = ds
ddlChangeType.D ataMember = "ChgType"
ddlChangeType.D ataTextField = "Type"
ddlChangeType.D ataBind()

End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
'How do I insert the values above?
End Sub
End Class

Nov 21 '05 #1
4 1345
The following KB article may be of some assistance, depending on your exact
circumstances.

http://support.microsoft.com/default...b;en-us;301248

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"robboll" <ro*****@hotmai l.com> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.com...
Please excuse my ignorance, but I am trying to teach myself .Net
without a lot of help. At this point I have created a page with a few
text boxes and combo boxes that I am using as an example.

The page displays nicely with the Requestor, DivMgr, ChgType,
Description fields.

What I would like to do at this point is create a Save button (at
bottom ref: Button1_Click) that, when clicked, inserts the data to the
table.

Can a .Net guru help with this one?
Thanks for the help in advance.

'************** *************** *************** *************** *
Imports System.Data.Sql Client

Public Class WebForm1
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Dim configurationAp pSettings As
System.Configur ation.AppSettin gsReader = New
System.Configur ation.AppSettin gsReader
Me.conn = New System.Data.Sql Client.SqlConne ction
'
'conn
'
Me.conn.Connect ionString =
CType(configura tionAppSettings .GetValue("conn .ConnectionStri ng",
GetType(System. String)), String)

End Sub
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
Protected WithEvents conn As System.Data.Sql Client.SqlConne ction
Protected WithEvents ddlRequestor As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected WithEvents ddlDivMgr As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Label2 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label3 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label4 As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label5 As System.Web.UI.W ebControls.Labe l
Protected WithEvents tbxDescription As
System.Web.UI.W ebControls.Text Box
Protected WithEvents tbxChangeName As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Label6 As System.Web.UI.W ebControls.Labe l
Protected WithEvents ddlChangeType As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Dim query As String
Dim ds As New DataSet
query = "select names from requestor order by names"
Dim da As New SqlDataAdapter( query, conn)
da.Fill(ds, "Requestor" )
ddlRequestor.Da taSource = ds
ddlRequestor.Da taMember = "Requestor"
ddlRequestor.Da taTextField = "names"
ddlRequestor.Da taBind()

query = "select DivMgr from DivMgr order by DivMgr"
Dim daDivMgr As New SqlDataAdapter( query, conn)
daDivMgr.Fill(d s, "DivMgr")
ddlDivMgr.DataS ource = ds
ddlDivMgr.DataM ember = "DivMgr"
ddlDivMgr.DataT extField = "DivMgr"
ddlDivMgr.DataB ind()

query = "select Type from ChgType order by Type"
Dim daChangeType As New SqlDataAdapter( query, conn)
daChangeType.Fi ll(ds, "ChgType")
ddlChangeType.D ataSource = ds
ddlChangeType.D ataMember = "ChgType"
ddlChangeType.D ataTextField = "Type"
ddlChangeType.D ataBind()

End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
'How do I insert the values above?
End Sub
End Class
Nov 21 '05 #2
Robboll,

In my opinion does it go to far if we try to complete the most difficult
part of your program.

However you are talking about comboboxes while you are using dropdownboxes
the combobox is a control from a winform and not from a webform.

It is therefore normal to assume than that you use a winform and not a
webform application (what I could only see in your code).

While when not tell in this newsgroup a winform is default.

Probably therefore you got from David a sample for a winform application.

There is a big different however probably you can use it, if you keep
remembering you that a weppage is not persistent. That means that you have
to save the data when you end your program (post the page) in a session
item.

response.sessio n.item("ds") = mydataset

When it is posted back you can load the dataset than again.

Have a look for that for that session and IsPostBack on MSDN.

I hope this helps,

Cor
Nov 21 '05 #3
As I said -- "excuse my ignorance" I am finally getting involved with
..Net and at this juncture a combobox is a dropdown is a "thingy that
you click on to display a list of values", etc. But I'm getting there.
The vernacular comes next. But thanks for the clarification.

Cor Ligthert wrote:
Robboll,

In my opinion does it go to far if we try to complete the most difficult
part of your program.

However you are talking about comboboxes while you are using dropdownboxes
the combobox is a control from a winform and not from a webform.

It is therefore normal to assume than that you use a winform and not a
webform application (what I could only see in your code).

While when not tell in this newsgroup a winform is default.

Probably therefore you got from David a sample for a winform application.

There is a big different however probably you can use it, if you keep
remembering you that a weppage is not persistent. That means that you have
to save the data when you end your program (post the page) in a session
item.

response.sessio n.item("ds") = mydataset

When it is posted back you can load the dataset than again.

Have a look for that for that session and IsPostBack on MSDN.

I hope this helps,

Cor


Nov 21 '05 #4
Thanks for the tip. I should be able to do something with it.

RBollinger

Nov 21 '05 #5

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

Similar topics

4
2436
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
6
2430
by: Jeff Kowalczyk | last post by:
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid, then an expanded version that will work on all orderids with a specific customerinvoiceid as a parameter. I'm sure appropriate joins will handle it, but I'm not making any headway, everything comes back with multiple tuple selected for update...
1
1602
by: Neo Geshel | last post by:
I am having conflicting results with two pieces of identical code. One is an insert, the other is an update to a db. The first code, which works, is this: Sub Add3_Click(sender As Object, e As EventArgs) Dim imgStream as Stream = Add3Image.PostedFile.InputStream Dim imgLen as Integer = Add3Image.PostedFile.ContentLength Dim imgType as String = Add3Image.PostedFile.ContentType If Not imgStream Is Nothing And imgLen > 0 And (imgType =
3
10332
by: equalive | last post by:
Hi guys, I'm having problem locking a table in Ms Access using VB6 code. Actually I have 3 tables. Assume table names is A, B, C. Following is the process. 1. Open table A and update table A. (Must Lock the table A) 2. Open table B and update table B.
3
2951
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news groups for years, I figure it's time for me to contribute a little bit back, maybe some people out there will find this useful. * Introduction This is a "how-to" style article, showing by example how to dynamically
2
11160
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new dataset to the project and drag a datatable from server explorer onto the dataset design surface. In the configuration wizard, under advanced options the "refresh data table" is disabled ie I am not able to check it (note if the source db is sql...
5
4105
by: rdemyan via AccessMonster.com | last post by:
I have a need to add another field to all of my tables (over 150). Not data, but an actual field. Can I code this somehow. So the code presumabley would loop through all the tables, open each table in design mode and then add the new field and set its properties. Thanks. --
0
1346
by: JimN1 | last post by:
Error: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. This is a continuation of my previous table element update question. I am now getting the above error message. I need help with the format of the SQLAdapter.Update(DSet.Tables(0)) command. I have included my code below. The line is in bold text. Imports System Imports System.Reflection Imports System.Text Imports System.Collections...
0
2047
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in house case number, appt date and time) for the applicants yearly history and the childs yearly history and then print a report with the applicants info and this in house case number. The forms are linked with ID_app (from the applicant table).
3
3970
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID = ?
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.