Solved

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

Posted on 2014-04-19
4
240 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
  • 2
  • 2
4 Comments
 
LVL 100

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 100

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now