| |
|||
|
Сначала извлекается список всех подразделений:
("select DepartmentID, DepartmentName " _ & "from IRDepartments Order By DepartmentName" _ , DBConn)
"Departments")
DSPageData.Tables("Departments").Defaultview ddlDepar tments.DataBind()
Dim DBConn as OleDbConnection Dim DBInsert As New OleDbCommand Dim DBCommand As OleDbDataAdapter Dim DSPageData as New DataSet Din; TheMessage as String Dim TheMailMessage as New MailMessage DBConn = New OleDbConnection("Provider-sqloledb;" _ & "server=localhost;" _ & "Initial Catalog=INETC5;" _ 4 "User Id=sa;" 4 "Password=yourpassword;") DBInsert.CommandText = "Insert Into IRs " _ & "(DepartmentID, Location, Description, " _ & "Impact, Prevention, Status) values (" _ & ddlDepartments.Selectedltem.Value & ", " _ & ""' & Replace(txtLocation.Text, "'", "''") & "', " & "'" & Replace (txtDescription. Text, ""', '"'") & "', " _ 4 "'" & Replace(txtlmpact.Text, "'", """) & "', " & "'" & Replace (txtPrevention. Text, "'", """) & "', " _ & "'Находится в рассмотрении')" DBInsert.Connection = DBConn DBInsert.Connection.Open DBInsert.ExecuteNonQuery() DBCommand = New OleDbDataAdapter _ ("Select Max(IRID) as ThelD " & "from IRs", DBConn) DBCommand.Fill(DSPageData, _ "NewID") DBCommand = New OleDbDataAdapter _ ("select ContactEmailAddress " _ & "from IRDepartments Where DepartmentID = " _ 4 ddlDepartments.Selectedltem.Value _ , DBConn) DBCommand.Fill(DSPageData, "Contact") TheMessage = "Получен новый отчет о происшествии. " _ 4 "Щелкните на ссылке для его прочтения." 4 chr(13) & chr(13) _ 4 "http://localhost/INetBook/C5/IR/SQL/ir_man.aspx" 4 "7IRID=" 4 DSPageData.Tables("NewID"). Rows(O).Item("TheID") TheMailMessage.From = webmaster@a.com TheMailMessage.To = DSPageData.Tables("Contact"). _ Rows(O).ItemC'ContactEmailAddress") TheMailMessage.Subject = "Новый отчет о происшествии" TheMailMessage.Body = TheMessage SmtpMail.Send(TheMailMessage) IblMessage.Text = "Сформированный отчет о происшествии отправлен." pnlForm.Visible = False End Sub
& "(DepartmentID, Location, Description, " _ & "Impact, Prevention, Status) values (" _ & ddlDepartments.Selectedltem.Value & ", " _ & "'" & Replace (txtLocation. Text, "'", "'"') & '", " _ & "'" & Replace(txtDescription.Text, "'", "'"') & "', " _ & "'" & Replace (txtlmpact. Text, "",""") & "', " & "'" & Replace(txtPrevention.Text, "'", "'"') & "', " _ & "'Находится в рассмотрении')"
DBInsert.Connection.Open
("Select Max(IRID) as ThelD " _ & "from IRs", DBConn) DBCommand.Fill(DSPageData, _ "NewlD") |
|||