Click here to Skip to main content
15,922,533 members
Home / Discussions / Database
   

Database

 
GeneralRe: REPLACE function doesn't always work Pin
PIEBALDconsult25-Mar-08 13:12
mvePIEBALDconsult25-Mar-08 13:12 
GeneralRe: REPLACE function doesn't always work Pin
adi.rusu25-Mar-08 22:17
adi.rusu25-Mar-08 22:17 
QuestionInsert Quert Creates problem Pin
Syed Shahid Hussain24-Mar-08 21:38
Syed Shahid Hussain24-Mar-08 21:38 
GeneralRe: Insert Quert Creates problem Pin
Christian Graus25-Mar-08 0:05
protectorChristian Graus25-Mar-08 0:05 
GeneralRe: Insert Quert Creates problem Pin
Vimalsoft(Pty) Ltd25-Mar-08 10:34
professionalVimalsoft(Pty) Ltd25-Mar-08 10:34 
QuestionQuery Problem Pin
Sadaf Naeem24-Mar-08 20:53
Sadaf Naeem24-Mar-08 20:53 
GeneralRe: Query Problem Pin
Christian Graus24-Mar-08 21:02
protectorChristian Graus24-Mar-08 21:02 
GeneralRe: Query Problem Pin
Sadaf Naeem24-Mar-08 23:10
Sadaf Naeem24-Mar-08 23:10 
Thanks for ur co-operation but let me briefly describe what i want

my query is changing based on the filters used .
to accomodate this situation , i have made a function GetData() which is being called after the user clicks on the button (btnFind) and they query is decided based on the filters specified by the user which means the parameters also change .

---Function GetData()----
private void GetData(string selectCommand)
{
// Specify a connection string. Replace the given value with a
// valid connection string for a Northwind SQL Server sample
// database accessible to your system.
string currentDirectory = System.Environment.CurrentDirectory;
OleDbConnection con = new OleDbConnection();

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + currentDirectory + "\\dbLetters.mdb';Persist Security Info=False";

// Create a new data adapter based on the specified query.
dataAdapter= new OleDbDataAdapter(selectCommand, con);

// Create a command builder to generate SQL update, insert, and
// delete commands based on selectCommand. These are used to
// update the database.
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);

// Populate a new data table and bind it to the BindingSource.
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
bindingSource1.DataSource = table;

// Resize the DataGridView columns to fit the newly loaded content.
dataGridView1.AutoResizeColumns(
DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
dataGridView1.DataSource = bindingSource1;
}

-------END--------

-----query specified-----

string command = "";

#region Sender of the letter is specified
else if (chkFrom.Checked == true && chkDate.Checked == false && chkSubject.Checked == false)
{


if (cmbFrom.SelectedItem.ToString() == "Others")
{
command = "Select * from tblIncomingLetters where From LIKE ='" + this.txtFrom.Text+ "'";
}
else
{
command = "Select * from tblIncomingLetters where From LIKE '" + cmbFrom.SelectedItem.ToString() + "'";
}
}
#endregion

#region date is specified
else if (chkDate.Checked == true && chkFrom.Checked == false && chkSubject.Checked == false)
{
command = "Select * FROM tblIncomingLetters where InwardDate Between " + dateTimePicker1.Value.Date+ " AND " + dateTimePicker2.Value.Date;

}
#endregion

#region subject is specfied

else if (chkDate.Checked == false && chkFrom.Checked == false && chkSubject.Checked == true)
{
command = "Select * from tblIncomingLetters where Subject LIKE '" + this.txtSubject.Text + "'";
}

#endregion
-------

Now plz tell me how to solve it or is there any other better way to achieve the same result.

I shall be really thankful 2 u

Sadaf

GeneralRe: Query Problem Pin
Christian Graus25-Mar-08 0:02
protectorChristian Graus25-Mar-08 0:02 
GeneralRe: Query Problem Pin
Sadaf Naeem24-Mar-08 23:14
Sadaf Naeem24-Mar-08 23:14 
GeneralRe: Query Problem Pin
Sadaf Naeem25-Mar-08 20:17
Sadaf Naeem25-Mar-08 20:17 
QuestionHow to get a list of temporary tables for a particular session. Pin
Sallu174924-Mar-08 20:14
Sallu174924-Mar-08 20:14 
AnswerRe: How to get a list of temporary tables for a particular session. Pin
Mark J. Miller25-Mar-08 6:52
Mark J. Miller25-Mar-08 6:52 
QuestionAsking for Help Pin
EvilInside24-Mar-08 19:15
EvilInside24-Mar-08 19:15 
GeneralRe: Asking for Help Pin
SimulationofSai24-Mar-08 20:29
SimulationofSai24-Mar-08 20:29 
GeneralRe: Asking for Help Pin
Vimalsoft(Pty) Ltd25-Mar-08 10:39
professionalVimalsoft(Pty) Ltd25-Mar-08 10:39 
QuestionGet Data Type of field/column? Pin
myNameIsRon24-Mar-08 16:55
myNameIsRon24-Mar-08 16:55 
AnswerRe: Get Data Type of field/column? Pin
John_Adams24-Mar-08 20:38
John_Adams24-Mar-08 20:38 
GeneralRe: Get Data Type of field/column? Pin
myNameIsRon25-Mar-08 9:18
myNameIsRon25-Mar-08 9:18 
Questionhow to add 7 days to my date filter Pin
hassanasp24-Mar-08 9:35
hassanasp24-Mar-08 9:35 
AnswerRe: how to add 7 days to my date filter Pin
Pete O'Hanlon24-Mar-08 10:42
mvePete O'Hanlon24-Mar-08 10:42 
AnswerRe: how to add 7 days to my date filter Pin
Sankar Komma 27-Mar-08 8:19
Sankar Komma 27-Mar-08 8:19 
GeneralComplicated query issue: need to specify strict return Pin
Vodstok24-Mar-08 8:49
Vodstok24-Mar-08 8:49 
GeneralRe: Complicated query issue: need to specify strict return Pin
Pete O'Hanlon24-Mar-08 10:45
mvePete O'Hanlon24-Mar-08 10:45 
GeneralRe: Complicated query issue: need to specify strict return Pin
A Wong25-Mar-08 5:11
A Wong25-Mar-08 5:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.