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

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
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
LucasPc
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.DateSelectedForm2.Show()
End SubEnd
Classform2 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 SubEnd
Classthe 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
LTD
fripper
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"