Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This video teaches viewers about errors in exception handling.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

747 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

13 Experts available now in Live!

Get 1:1 Help Now