Solved

How do I get data that doesn't change from a database?

Posted on 2014-04-19
4
247 Views
Last Modified: 2014-04-20
Scholarfest 2014 is a record in the database, but I can't figure out how to retrieve it. Any help would be greatly appreciated.

Imports System.Data
Imports System.Data.SqlClient
Imports System.Net.Mail
Imports System.Data.OleDb
Imports System.DateTime

Partial Class Submit
    Inherits System.Web.UI.Page
    Dim objdt As System.Data.DataTable
    Dim objdr As System.Data.DataRow
    Dim allthemes As String = ""
    Dim ds As New DataSet
    Dim i As Integer
    Dim strtheme As String
    Dim savenow As DateTime = DateTime.Now





    Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
        Dim strConnection As String = "Data Source=mssql102.manage.myhosting.com;Initial Catalog=db1150602_group3;Integrated Security=False;User ID=u1150602_drnicholsongroup3;Password=w6p?K9x!,l;Connect Timeout=15;Encrypt=False;Packet Size=4096"
        Dim objconnection As New SqlConnection(strConnection)
        Dim mysqlDataAdapter As New SqlDataAdapter("select * From Publication", objconnection)
        'Using conn As New SqlConnection(strConnection)
        'Using()  cmd As New SqlCommand(selecteditems, conn)
        'cmd.Parameters.AddWithValue("@CheckBoxList1", CheckBoxList1.Items)

        'conn.Open()

        'selecteditems = DirectCast(cmd.ExecuteScalar(), String)
        'End Using
        'End Using
        Dim myDataRow As DataRow
        Dim mydatarowscommandbuilder As New SqlCommandBuilder(mysqlDataAdapter)


        mysqlDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
        mysqlDataAdapter.Fill(ds, "Publication")

        myDataRow = ds.Tables("Publication").NewRow()
        myDataRow("PubTypeID") = DropDownList1.SelectedItem
        myDataRow("Addinfo") = txtAddInfo.Text
        myDataRow("coAuthor") = txtCoAuthor.Text
        myDataRow("coAuthor2") = txtCoAuthor2.Text
        myDataRow("coAuthor3") = txtCoAuthor3.Text
        myDataRow("coAuthor4") = txtCoAuthor4.Text
        myDataRow("coAuthor5") = txtCoAuthor5.Text
        myDataRow("Themes") = CheckBoxList1.Items
        myDataRow("PubDate") = DateTime.Now
        myDataRow("WorkTitle") = txtWorkTitle.Text
        myDataRow("AuthorFName") = txtFirstName.Text
        myDataRow("AuthorLName") = txtLastName.Text
        myDataRow("AuthorEmail") = txtEmail.Text
        ds.Tables("Publication").Rows.Add(myDataRow)
        myDataRow("FacultyID") = Session("user")
        'myDataRow("EventID") = Scholarfest 2014?
        mysqlDataAdapter.Update(ds, "Publication")

        txtAddInfo.Text = ""
        txtCoAuthor.Text = ""
        txtCoAuthor2.Text = ""
        txtCoAuthor3.Text = ""
        txtCoAuthor4.Text = ""
        txtCoAuthor5.Text = ""
        txtWorkTitle.Text = ""
        txtFirstName.Text = ""
        txtLastName.Text = ""
        txtEmail.Text = ""


        Try
            Dim Smtp_Server As New SmtpClient
            Dim e_mail As New MailMessage()
            Smtp_Server.UseDefaultCredentials = False
            Smtp_Server.Credentials = New Net.NetworkCredential("username@rowan.edu", "password")
            Smtp_Server.Port = 587
            Smtp_Server.EnableSsl = True
            Smtp_Server.Host = "smtp.gmail.com"
            e_mail = New MailMessage()
            e_mail.From = New MailAddress("username@rowan.edu")
            e_mail.To.Add("username@rowan.edu")
            e_mail.Subject = "Email Sending"
            e_mail.IsBodyHtml = False
            e_mail.Body = txtFirstName.Text
            e_mail.Body = txtLastName.Text
            e_mail.Body = DropDownList1.DataTextField
            e_mail.Body = txtWorkTitle.Text
            e_mail.Body = txtCoAuthor.Text
            e_mail.Body = txtCoAuthor2.Text
            e_mail.Body = txtCoAuthor3.Text
            e_mail.Body = txtCoAuthor4.Text
            e_mail.Body = txtCoAuthor5.Text

            e_mail.Body = txtAddInfo.Text
            Smtp_Server.Send(e_mail)
            MsgBox("Mail Sent") '
        Catch error_t As Exception
            MsgBox(error_t.ToString)
        End Try


    End Sub




    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles btnAdd.Click

        If (txtCoAuthor2.Visible = False) Then

            txtCoAuthor2.Visible = True
            Return

        End If

        If (txtCoAuthor3.Visible = False) Then



            txtCoAuthor2.Visible = True
            txtCoAuthor3.Visible = True
            Return
        End If


        If (txtCoAuthor4.Visible = False) Then



            txtCoAuthor2.Visible = True
            txtCoAuthor3.Visible = True
            txtCoAuthor4.Visible = True
            Return
        End If

        If (txtCoAuthor5.Visible = False) Then

            txtCoAuthor2.Visible = True
            txtCoAuthor3.Visible = True
            txtCoAuthor4.Visible = True
            txtCoAuthor5.Visible = True
            Return
        End If

        getThemes()

    End Sub

    Public Sub getThemes()
        Dim i As Integer
        Dim chkbx As CheckBoxList
        chkbx = CType(FormView1.FindControl("CheckBoxList1"), CheckBoxList)
        Dim sb As StringBuilder = New StringBuilder()
        For i = 0 To chkbx.Items.Count - 1
            If chkbx.Items(i).Selected Then
                sb.Append(chkbx.Items(i).Value & ",")
            End If
        Next
        'Create the value to be inserted by removing the last comma in sb
        Dim InputValue As String
        InputValue = Left(sb.ToString(), Len(sb.ToString()) - 1)

    End Sub



End Class

Open in new window

0
Comment
Question by:ryanbecker24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 40011374
Is ScholarFest 2014 a value in a column in the database?

mlmcc
0
 

Author Comment

by:ryanbecker24
ID: 40011403
Yes
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 40011814
Are you trying to set Event ID to have ScholarFest 2014?

Have you tried

myDataRow("EventID") = "Scholarfest 2014"

mlmcc
0
 

Author Comment

by:ryanbecker24
ID: 40011843
Thanks, it didn't work because it was in the Event table.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question