Code to update the table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • robboll

    #1

    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

  • David Lloyd

    #2
    Re: Code to update the table

    The following KB article may be of some assistance, depending on your exact
    circumstances.



    --
    David Lloyd
    MCSD .NET
    Award-winning Managed I.T. Services, I.T. Consulting, cloud solutions, database hosting, and A.I. software development for organizations nationwide.


    This response is supplied "as is" without any representations or warranties.


    "robboll" <robboll@hotmai l.com> wrote in message
    news:1117563844 .955493.13170@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


    Comment

    • Cor Ligthert

      #3
      Re: Code to update the table

      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


      Comment

      • robboll

        #4
        Re: Code to update the table

        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:[color=blue]
        > 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[/color]

        Comment

        • robboll

          #5
          Re: Code to update the table

          Thanks for the tip. I should be able to do something with it.

          RBollinger

          Comment

          Working...