none
Please help me regarding LINQ RRS feed

  • Question

  • I am making a project in VB 2008 for Automated Car Parking System (Front End & its connection with Access 07).

    I want to add a searching algorithm to find a free slot from the database containing 2 tables: 1)Block: (Blockno, Occupancy)

                                                                                                                                          2)Cust:  (Cust_id, Car_no, Blockno)

    Now I want to allocate the Blockno to be provided according to the searching algorithm to the customer.

    Please tell me "How to use LINQ for this purpose?"

    My final output must be a message box displaying the block no to the customer, where the car is parked...........

    Pls help.........

     

    • Moved by Mike FengModerator Tuesday, March 8, 2011 2:21 AM LINQ (From:Visual Basic Language)
    Sunday, March 6, 2011 1:01 PM

Answers

  • if I'm understanding this correctly, it looks like you'll need 3 different SQL statements for different functions in your app:

    1.  a SELECT query searching for empty slots from Block, using a WHERE clause (WHERE Occupancy = False). Of course this is assuming Occupancy is a Boolean column

    2. an INSERT statement to insert the Customer data into Cust, and also UPDATE into Block changing Occupancy = True

    3. another SELECT query to find the blockno, using WHERE Cust_id = <customerID>, which you can display in a MessageBox. And of course then updating the Block table so the Occupancy = False

    have a look through these to get an idea how to query the database

    http://www.w3schools.com/SQL/default.asp

     

    Sunday, March 6, 2011 3:42 PM
  • Hello Rohit28,

     

    Thanks for your post.

    According to your description, I think what you mean is that you called AvailabilityTableAdapter.Update(DataSet1) method but it didn't work. right?

    If so, there's a DataSet FAQ named

    There are another two way to try:
    1. It is a good idea to call DataSource.EndEdit() before Adapter.Update(). To pull in all changes from the controls.

    2. If there are Foreign Key relations between  tables and one of the others you will have to split up Insert/Update and Delete actions, or use a TableAdaptermanager

    I hope this can help.

     

    Have a nice day,

    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 9, 2011 5:49 AM
    Moderator

All replies

  • if I'm understanding this correctly, it looks like you'll need 3 different SQL statements for different functions in your app:

    1.  a SELECT query searching for empty slots from Block, using a WHERE clause (WHERE Occupancy = False). Of course this is assuming Occupancy is a Boolean column

    2. an INSERT statement to insert the Customer data into Cust, and also UPDATE into Block changing Occupancy = True

    3. another SELECT query to find the blockno, using WHERE Cust_id = <customerID>, which you can display in a MessageBox. And of course then updating the Block table so the Occupancy = False

    have a look through these to get an idea how to query the database

    http://www.w3schools.com/SQL/default.asp

     

    Sunday, March 6, 2011 3:42 PM
  • Hi Rohit28,

     

    I have moved this thread to

    LINQ to SQL: http://social.msdn.microsoft.com/Forums/en-US/linqtosql/threads forum where you may get much better support because more this aspect experts live there.

    Thanks for your understanding.

     

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 8, 2011 2:21 AM
    Moderator
  • Hi,

    Thanks for replying.

    Actually, my main motive is to find out the block number (Blockno) from the available list (where Occupancy = False)

    using a searching algorithm.  After obtaining the Blockno I will be leaving a message box displaying customer's id and alloted blockno.

    Now I have written a query in Access 07 (which I am using as a back end), which shows all information about the available blocks.The name of this table is 'Availability'. Among the available blocks, I will be allocating the first record to the current requesting customer.

    But, when I try to update Availability using AvailabilityTableAdapter.Update(DataSet1), it isn't get updated. Also 'Update is not even in the property list of AvailabilityTableAdapter.

    Now tell me how do I update?

    Regards,

    Rohit28

    Wednesday, March 9, 2011 4:50 AM
  • Hello Rohit28,

     

    Thanks for your post.

    According to your description, I think what you mean is that you called AvailabilityTableAdapter.Update(DataSet1) method but it didn't work. right?

    If so, there's a DataSet FAQ named

    There are another two way to try:
    1. It is a good idea to call DataSource.EndEdit() before Adapter.Update(). To pull in all changes from the controls.

    2. If there are Foreign Key relations between  tables and one of the others you will have to split up Insert/Update and Delete actions, or use a TableAdaptermanager

    I hope this can help.

     

    Have a nice day,

    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 9, 2011 5:49 AM
    Moderator