Solved

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

Posted on 2014-04-19
4
242 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

776 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