R
robboll
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.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Dim configurationAppSettings As
System.Configuration.AppSettingsReader = New
System.Configuration.AppSettingsReader
Me.conn = New System.Data.SqlClient.SqlConnection
'
'conn
'
Me.conn.ConnectionString =
CType(configurationAppSettings.GetValue("conn.ConnectionString",
GetType(System.String)), String)
End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents conn As System.Data.SqlClient.SqlConnection
Protected WithEvents ddlRequestor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents ddlDivMgr As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents tbxDescription As
System.Web.UI.WebControls.TextBox
Protected WithEvents tbxChangeName As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents ddlChangeType As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.DataSource = ds
ddlRequestor.DataMember = "Requestor"
ddlRequestor.DataTextField = "names"
ddlRequestor.DataBind()
query = "select DivMgr from DivMgr order by DivMgr"
Dim daDivMgr As New SqlDataAdapter(query, conn)
daDivMgr.Fill(ds, "DivMgr")
ddlDivMgr.DataSource = ds
ddlDivMgr.DataMember = "DivMgr"
ddlDivMgr.DataTextField = "DivMgr"
ddlDivMgr.DataBind()
query = "select Type from ChgType order by Type"
Dim daChangeType As New SqlDataAdapter(query, conn)
daChangeType.Fill(ds, "ChgType")
ddlChangeType.DataSource = ds
ddlChangeType.DataMember = "ChgType"
ddlChangeType.DataTextField = "Type"
ddlChangeType.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'How do I insert the values above?
End Sub
End Class
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.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Dim configurationAppSettings As
System.Configuration.AppSettingsReader = New
System.Configuration.AppSettingsReader
Me.conn = New System.Data.SqlClient.SqlConnection
'
'conn
'
Me.conn.ConnectionString =
CType(configurationAppSettings.GetValue("conn.ConnectionString",
GetType(System.String)), String)
End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents conn As System.Data.SqlClient.SqlConnection
Protected WithEvents ddlRequestor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents ddlDivMgr As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents tbxDescription As
System.Web.UI.WebControls.TextBox
Protected WithEvents tbxChangeName As
System.Web.UI.WebControls.TextBox
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents ddlChangeType As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.DataSource = ds
ddlRequestor.DataMember = "Requestor"
ddlRequestor.DataTextField = "names"
ddlRequestor.DataBind()
query = "select DivMgr from DivMgr order by DivMgr"
Dim daDivMgr As New SqlDataAdapter(query, conn)
daDivMgr.Fill(ds, "DivMgr")
ddlDivMgr.DataSource = ds
ddlDivMgr.DataMember = "DivMgr"
ddlDivMgr.DataTextField = "DivMgr"
ddlDivMgr.DataBind()
query = "select Type from ChgType order by Type"
Dim daChangeType As New SqlDataAdapter(query, conn)
daChangeType.Fill(ds, "ChgType")
ddlChangeType.DataSource = ds
ddlChangeType.DataMember = "ChgType"
ddlChangeType.DataTextField = "Type"
ddlChangeType.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'How do I insert the values above?
End Sub
End Class