Forgive the noob.
Excel 2010 + VB.net 2010 express
I have a vb.net project that connects to an excel workbook (oledb) and fills it with user entered data on a daily basis.
It works great!
The excel sheet has 15 Columns and the data expands downward as users input data every day. Each row is a different record.
One of my columns, (N) is one titled "CallbackRequired" which will only have "Yes" or "No" and another column (O) is "WhenCall" which saves the date the customer is to be called back on.
In my vb.net application, I would like to put either a label or a textbox on a form that will display at runtime all the records in that sheet under the column "CallbackRequired" that have a "Yes" that match only the current date in the "WhenCall" column.
I would like to display the entire row of 15 columns (the record) that match the critera I just described on a number delimited list, 1 per row when the program is run.
I figure this is most likely done with a SQL statement but I know not how to construct one. I am sure that I could muddle through the statement itself
<noob but="" not="" stupid=""> but I am not sure, (even if I had the correct syntax), how to display or return the data I am requesting.
Although I don't think you need to see the code to help me with this question I have included it anyway for reference.
Any help is greatly appreciated.
Try
olecon = New OleDb.OleDbConnection
olecon.ConnectionString = connstring
olecomm = New OleDb.OleDbCommand
olecomm.CommandText = _
"Select TodaysDate, CustomersName, CustomersPhoneNumber, Last4ofSS, Billing, UpgradeAvailable, HowMany, HPC, MBB, GWG, SellDevice, HowManyTwo, Comments, CallbackRequired, WhenCall from [Traffic Monitor$]"
olecomm.Connection = olecon
olecomm1 = New OleDb.OleDbCommand
olecomm1.CommandText = "Insert into [Traffic Monitor$] " & _
"(TodaysDate, CustomersName, CustomersPhoneNumber, Last4ofSS, Billing, UpgradeAvailable, HowMany, HPC, MBB, GWG, SellDevice, HowManyTwo, Comments, CallbackRequired, WhenCall) values " & _
"(@tDate, @tName, @tNumb, @tLast, @tBill, @tUp, @tHow, @tHPC, @tMBB, @tGWG, @tDevice, @tHowTwo, @tComm, @tCall, @tWhen)"
olecomm1.Connection = olecon
pram = olecomm1.Parameters.Add("@tDate", OleDb.OleDbType.VarChar)
pram.SourceColumn = "TodaysDate"
pram = olecomm1.Parameters.Add("@tName", OleDb.OleDbType.VarChar)
pram.SourceColumn = "CustomersName"
pram = olecomm1.Parameters.Add("@tNumb", OleDb.OleDbType.VarChar)
pram.SourceColumn = "CustomersPhoneNumber"
pram = olecomm1.Parameters.Add("@tLast", OleDb.OleDbType.VarChar)
pram.SourceColumn = "Last4ofSS"
pram = olecomm1.Parameters.Add("@tBill", OleDb.OleDbType.VarChar)
pram.SourceColumn = "Billing"
pram = olecomm1.Parameters.Add("@tUp", OleDb.OleDbType.VarChar)
pram.SourceColumn = "UpgradeAvailable"
pram = olecomm1.Parameters.Add("@tHow", OleDb.OleDbType.VarChar)
pram.SourceColumn = "HowMany"
pram = olecomm1.Parameters.Add("@tHPC", OleDb.OleDbType.VarChar)
pram.SourceColumn = "HPC"
pram = olecomm1.Parameters.Add("@tMBB", OleDb.OleDbType.VarChar)
pram.SourceColumn = "MBB"
pram = olecomm1.Parameters.Add("@tGWG", OleDb.OleDbType.VarChar)
pram.SourceColumn = "GWG"
pram = olecomm1.Parameters.Add("@tDevice", OleDb.OleDbType.VarChar)
pram.SourceColumn = "SellDevice"
pram = olecomm1.Parameters.Add("@tHowTwo", OleDb.OleDbType.VarChar)
pram.SourceColumn = "HowManyTwo"
pram = olecomm1.Parameters.Add("@tComm", OleDb.OleDbType.VarChar)
pram.SourceColumn = "Comments"
pram = olecomm1.Parameters.Add("@tCall", OleDb.OleDbType.VarChar)
pram.SourceColumn = "CallbackRequired"
pram = olecomm1.Parameters.Add("@tWhen", OleDb.OleDbType.VarChar)
pram.SourceColumn = "WhenCall"
oleadpt = New OleDb.OleDbDataAdapter(olecomm)
ds = New DataSet
olecon.Open()
oleadpt.Fill(ds, "Traffic Monitor")
ds.Tables(0).Rows.Add(dr)
oleadpt = New OleDb.OleDbDataAdapter
oleadpt.InsertCommand = olecomm1
Dim i As Integer = oleadpt.Update(ds, "Traffic Monitor")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
olecon.Close()
olecon = Nothing
olecomm = Nothing
oleadpt = Nothing
ds = Nothing
dr = Nothing
pram = Nothing
End Try