Click here to Skip to main content
13,088,846 members (69,303 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

Please check the below code

If (DateTime.Now = "01/01/2013") Then
               Dim sql00 = "select sum(EL),sum(ML) from attendance where Emp_name = '" + ComboBox1.Text + "'"
               Dim sql000 = sql00 + " SELECT 15+ sum(EL) as el, 14 + sum(ML) as ml from attendance where Emp_name = '" + ComboBox1.Text + "' "
           End If

Please tell me whether the code is correct or not and i want to display the value of sql000 to a existing gridview...

please tell me how to do it..
Posted 29-Oct-12 20:11pm
vivektiwari97701 30-Oct-12 2:30am
u have written 2 select Query and mearge that in to sql1000 its totaly wrong ...pls explain wat is ur requrment ??/
snehasish nandy 30-Oct-12 2:33am
my requirement is if the date hits 1/1/2013 then it should add the result of the first query(i.e. it will give the remaining leaves of a particular emp) to the nxt query(i.e. predefined number of leaves for each emp) and the result i want to display in the gridview
satz_770 30-Oct-12 2:38am
hi, u need to display result of both queries in the same gridview or different??... u cant execute two queries that is in same variable.. u can execute it separately... u have not executed query... Execute it to get result and then bind it to grid....
snehasish nandy 30-Oct-12 2:40am
I want to display in same gridview..but not getting how to add the quries..please tell me some examples
satz_770 30-Oct-12 3:19am
No use in adding two queries..
1. Execute the first query and Get the result..
2. Execute the second query and get the result..
3. add both the results based on ur requirement..
if u have any clarifications reply to this..
snehasish nandy 30-Oct-12 3:20am
Give me some example...
shanalalkasim 30-Oct-12 3:02am
U have not executed query,
1. Execute query
2. fetch the result
3. Bind it to grid
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

just update your query

select sum(EL),sum(ML),15+ sum(EL) as el, 14 + sum(ML) as ml from attendance where Emp_name = '" + ComboBox1.Text + "'"
snehasish nandy 30-Oct-12 3:04am
Thanks @vivektiwari97701
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


Here is the code to connect to the database in Ms Access.

Connection string for MS Access via OLE DB:
Dim connection As OleDbConnection
connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NorthWind.mdb;User Id=;Password=;")

After connecting to the database

dim da as new oledb.oledbdataadapter("your query",connection)
dim ds as new dataset

Now u can set the data to the grid....

DataGridView1.DataSource = ds
DataGridView1.DataMember = "table name"

Hope this helps

Refer these:[^][^]

mark it if u find it usseful....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 30 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100