calender link to database

I'm trying to create a database of projects. when a project is entered i want the entered to link the database info for that project to the calender date so that when a user clicks on a calender day the projects for that day are shown in a message box. Any ideas

Thanks



Answer this question

calender link to database

  • Deb Magsam

    your connectionstring is incorrect. a connection string looks like this typically:

    "data source=.;initial catalog=databaseName;Trusted_Connection=true;"

    this is what you have to put in but of course changing the various names. if you have a connectionstring in your project which you want to use, find that string and place it in, without quotes, as long as its a string type



  • gibic

    I still get the innerexception error as before.
  • Girb

    typo! my equals key does not seem to work correctly:

    dateChosen.Value = My.Forms.Form1.MonthCalendar1.SelectionStart



  • VitaminB6

    I tried the previous code. I ended up getting the following error.

    System.ArgumentException was unhandled
    Message="Format of the initialization string does not conform to specification starting at index 0."

    any ideas

    Thanks


  • HScottBuck

    what goes in the place of initial catalog
  • LucasPc

    yes. i want to show the user all projects with that date. the specific day is picked using the monthcalender control.
  • Sam_res03

    here is the form1 code

    Public Class Form1

    Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected

    Form2.Show()

    End Sub

    End Class

    form2 code is

    Public Class Form2

    Private Sub ProjectsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProjectsBindingNavigatorSaveItem.Click

    Me.Validate()

    Me.ProjectsBindingSource.EndEdit()

    Me.ProjectsTableAdapter.Update(Me.ProjectsDataSet.Projects)

    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Me.ProjectsTableAdapter.Fill(Me.ProjectsDataSet.Projects)

    Dim theDataSet As New DataSet()

    Dim theCommand As New SqlClient.SqlCommand("SELECT * FROM [Projects] WHERE [Date] = @dateChosen", New SqlClient.SqlConnection("ProjectsConnectionString"))

    Dim ProjectsDataAdapter As New SqlClient.SqlDataAdapter(theCommand)

    Dim dateChosen As New SqlClient.SqlParameter("@dateChosen", SqlDbType.DateTime, 8, My.Forms.Form1.MonthCalendar1.SelectionStart)

    theCommand.Parameters.Add(dateChosen)

    theCommand.Connection.Open()

    ProjectsDataAdapter.Fill(ProjectsDataSet)

    theCommand.Connection.Close()

    Me.ProjectsDataGridView.DataSource = ProjectsDataSet.Tables(0).DefaultView

    End Sub

    End Class

    the error points at the form2.show()

    the error is: An error occurred creating the form. See Exception.InnerException for details. The error is: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.


  • Missis Crystal

    hmmm - which line was it pointing at could you also post your version of code ive also spotted a small mistake...try re-doing the code and see if it works ;-)

  • LTD

    i think the connectionstring shown below are incorrect...
  • fripper

    if I understand correctly, say you have details of a project stored in a database including the date of that project. From the winforms app, when the user selects a data using say a datetime picker control or a month calander, you wish to retrieve that date of project, if stored in the database, from the database and show it to the user is this correct

  • David Hills

    the name of the database you are connecting to :-)

    you also need to be aware of which SQL Server instance/version you are using. Check here for connection strings:

    http://www.connectionstrings.com



  • srishu

    generally its simple.

    we will do a small example.

    you simply need to query the database with the data value chosen from say a monthcalander control. So we could fill a dataset with the results and bind that to a datagridview.

     

    Dim theDataSet as new DataSet()

    Dim theCommand as new SqlCommand("SELECT * FROM [TableName] WHERE [DateField] = @dateChosen", new SqlConnection("ConnectionString"))

    Dim theDataAdapter as new SqlDataAdapter(theCommand)

    Dim dateChosen as new SqlParameter("@dateChosen", SqlDbType.DateTime, 8)

    dateChosen.Value = Me.theCalander.SelectionStart

    theCommand.Parameters.Add(dateChosen)

     

    theCommand.Connection.Open()

    theDataAdapter.Fill(theDataSet)

    theCommand.Connection.Close()

     

    Me.theDataGridView.DataSource = theDataSet.Tables(0).DefaultView

     

    this should, in this example, get the records based on the date given from the calander control



  • Sats_b1

    change this:

    Dim dateChosen As New SqlClient.SqlParameter("@dateChosen", SqlDbType.DateTime, 8, My.Forms.Form1.MonthCalendar1.SelectionStart)

    to this:

    Dim dateChosen As New SqlClient.SqlParameter("@dateChosen", SqlDbType.DateTime, 8)

    dateChosen.Value My.Forms.Form1.MonthCalendar1.SelectionStart

    what happens now



  • LKeene

    vb underlines "dateChosen.Value(My.Forms.Form1.MonthCalendar1.SelectionStart)"

    and says"property access must assign to the property or use its value"


  • calender link to database