|
What type is the database-column? Is it a datetime, or a text-type? How does your query look? Are you sure the datetime-values are parsed correctly?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Sounds like you have an issue with differences in cultures. In other words, the data that you are retrieving is stored as one date culture, and the UI is using a different date culture.
|
|
|
|
|
Be careful - the value retrieved from the DateTimePicker may contain a Time also - remove that before you enter the value into your query.
|
|
|
|
|
Hi friends!
Thanks for your messages. My query down below;
"SELECT COMPANY_NAME,PRODUCT_NAME,P_STATUS,IMPORT_DATE WHERE IMPORT_DATE BETWEEN '" + dateTimePicker1.Value.ToString() + "' AND '" + dateTimePicker2.Value.ToString() + "' "
Database column is a datetime so is datetimepicker value. There are no errors but it shows only one date. I checked data types many times but what is wrong with this query?
|
|
|
|
|
Pete already pointed out that there might be a preblem with different formats (e.g. due to different cultures). Avoid that problem by using a parameterized query.
And as I told you above, remove the Time component of the value. dateTimePicker1.Value.Date will help you (and no: do not add a ToString()!).
|
|
|
|
|
I have done everything you said but it didn't work. So is there any other way to solve that problem? My new query that didn't work down below;
"SELECT COMPANY_NAME,PRODUCT_NAME,P_STATUS,IMPORT_DATE WHERE IMPORT_DATE BETWEEN '" + dateTimePicker1.Value.Date + "' AND '" + dateTimePicker2.Value.Date + "' "
Thanks & Best Regards For Your Support..
|
|
|
|
|
That will still convert the date to a string-representation. Use a parameterized query;
MyCommand.CommandText = "SELECT COMPANY_NAME,PRODUCT_NAME,P_STATUS,IMPORT_DATE WHERE IMPORT_DATE BETWEEN @Param1 AND @Param2";
MyCommand.Parameters.AddWithValue("@Param1", dateTimePicker1.Value);
MyCommand.Parameters.AddWithValue("@Param2", dateTimePicker2.Value);
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
I'm trying to create a automatic login for a website... the problem is that the website keep giving me this error "Incorrect Email/Password Combination"...
However when i login manually with the exact username and pass that i used in the code... it works!!!
this is strange coz the code seems to work correct! it inserts the username and password into the editboxes and clicks the button called "login"... but then it returns the error!
Here is the code that i usually use:
public void EditboxFill(string Elementid, string TEXT)
{
wb.Document.GetElementById(Elementid).SetAttribute("value", TEXT);
}
public void ElementClick(string Elementid)
{
wb.Document.GetElementById(Elementid).InvokeMember("click");
}
public void Login()
{
ElementClick("sbxJxRegEmail");
EditboxFill("sbxJxRegEmail", "EMAIL");
ElementClick("sbxJxRegPswd");
EditboxFill("sbxJxRegPswd", "PASSWORD");
ElementClick("LoginBtn");
}
i don't think there is any errors in the code... as its the same code that i have used in previous projects, so i guess the site is just being difficult.
its strange that it works manually but not with the code... Therefore i think that i might have something to do with how the user clicks on the Textboxes.
The Textboxs have a PLACEHOLDER that is removed once the user clicks the text in the textbox... Prehaps because the actual text isn't being being clicked but only REPLACED... the site is using my login details as the PLACEHOLDERs... and treats my request as if no text has been entered.
when i try to login manually with empty values... i still get the error : "Incorrect Email/Password Combination"
so... any suggestions on fixing this???
|
|
|
|
|
It could be anyghing from a missing mouse hover event to a focus event. Why don't you use a tool for your browser and debug the website's javascript code.
BTW, what website are you talking about here?
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
the website is called swagbucks.com
USERNAME input:
<input id="sbxJxRegEmail" class="sbxJxRegEmailEmpty" type="text" tabindex="1" data-active-state="sbxJxRegEmailFocus" value="" data-placeholder="Email Address or Swag Name" placeholder="Email Address or Swag Name" name="emailAddress" autofocus="autofocus"></input>
PASSWORD input:
<input id="sbxJxRegEmail" class="sbxJxRegEmailEmpty" type="text" tabindex="1" data-active-state="sbxJxRegEmailFocus" value="" data-placeholder="Email Address or Swag Name" placeholder="Email Address or Swag Name" name="emailAddress" autofocus="autofocus"></input>
submit Button:
<input id="sbxJxRegEmail" class="sbxJxRegEmailEmpty" type="text" tabindex="1" data-active-state="sbxJxRegEmailFocus" value="" data-placeholder="Email Address or Swag Name" placeholder="Email Address or Swag Name" name="emailAddress" autofocus="autofocus"></input>
i use these IDs in my code, it enters the username and password correctly and clicks the button.
however i believe the textboxs are submitted as blanks because i dont actually CLICK to edit them!
so what im looking for is code that will CLICK THE actual TEXT inside the editbox ... perhaps a Setfocus ???
IF this is not possible... What would be an alternative to login? Can i do this with WebRequests?
|
|
|
|
|
|
|
0) No, it's not urgent for us.
1) You should have posted this question in ASP.NET forum[^]
2) What have you tried?
3) Did you search Google?
4) Here a simple idea for solution.
Consider you have a table like below, add another column DisplayOrder
----------------------------------
CountryID CountryName DisplayOrder
----------------------------------
1 US 3
2 UK 2
3 India 1
----------------------------------
Now, write a query with sorting order - DisplayOrder column
SELECT CountryID, CountryName, DisplayOrder FROM TblCountry ORDER BY DisplayOrder ASC;
Now bind the query to DropDownlist .
5) From next time, follow this[^]
|
|
|
|
|
Hi,
I've been trying to get data from sql database within selected dates defined by datetimepicker. I've followed all necessary connection setup and query but there is this error SqlCeException at da.Fill(ds1, "upnp_daily"). It says a parameter is missing. I have tried all means but I couldn't spot where exactly goes wrong.
The following is my code. I really do appreciate it if someone could help me. Thanks in advance!
//-----Code-----
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da;
DataSet ds1;
private void connectSQLserver()
{
//Connecting to SQL Server Express Database
string strDataSource = @"Data Source=C:\Visual Studio 2010\Projects\UPNP_Form_F\UPNP_Form_F\bin\Debug\upnp_database.sdf";
con = new System.Data.SqlServerCe.SqlCeConnection();
con.ConnectionString = strDataSource;
con.Open();
ds1 = new DataSet();
SqlCeCommand cmd = new SqlCeCommand();
cmd.CommandText = "SELECT * FROM upnp_daily_energy WHERE Date >= @p_StartDate AND Date <= @p_EndDate";
cmd.Parameters.Add("@p_StartDate", SqlDbType.DateTime).Value = dtpSTART; //get date from date time picker
cmd.Parameters.Add("@p_EndDate", SqlDbType.DateTime).Value = dtpEND;
cmd.Connection = con;
da = new System.Data.SqlServerCe.SqlCeDataAdapter(cmd.CommandText, cmd.Connection);
try //run the query
{
da.Fill(ds1, "upnp_daily"); //run the query
}
catch (Exception e2)
{
MessageBox.Show("Error 7: " + e2.ToString()); //<<--- Error here!
}
MessageBox.Show("Connection Open"); //<<---DEBUG
MaxRows = ds1.Tables["upnp_daily"].Rows.Count; //get no of rows in DataSet
MessageBox.Show("No of rows in DataSet = " + MaxRows.ToString());
}//------------------------------------------------------------------------------------
modified 28-Nov-13 2:33am.
|
|
|
|
|
I'm not that surprised:
cmd.Parameters.Add("@p_StartDate", SqlDbType.DateTime).Value = dtpSTART; No, it doesn't.
It tries to pass a DateTimePicker control into the parameter as a DateTime value!
Try this:
cmd.Parameters.Add("@p_StartDate", SqlDbType.DateTime).Value = dtpSTART.Value;
cmd.Parameters.Add("@p_EndDate", SqlDbType.DateTime).Value = dtpEND.Value; Or better:
cmd.Parameters.AddWithValue("@p_StartDate", dtpSTART.Value);
cmd.Parameters.AddWithValue("@p_EndDate", dtpEND.Value);
|
|
|
|
|
oh yes. I was silly. I should be passing dtpSTART.Value.
But the same error still remains and all my database data is wiped out everytime I call this upon a button click. Here is what I have implement. Could you please kindly take a look? I'm really quite at a loss.
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da;
DataSet ds1;
private void btnGetData_Click(object sender, EventArgs e)
{
connectSQLserver();
updateDS();
closeSQLserver();
}
private void connectSQLserver()
{
string strDataSource = @"Data Source=C:\Visual Studio 2010\Projects\UPNP_Form_F\UPNP_Form_F\bin\Debug\upnp_database.sdf";
con = new System.Data.SqlServerCe.SqlCeConnection();
con.ConnectionString = strDataSource;
con.Open();
ds1 = new DataSet();
SqlCeCommand cmd = new SqlCeCommand();
cmd.CommandText = "SELECT * FROM upnp_daily_energy WHERE Date >= @p_StartDate AND Date <= @p_EndDate";
cmd.Parameters.AddWithValue("@p_StartDate", dtpSTART.Value);
cmd.Parameters.AddWithValue("@p_EndDate", dtpEND.Value);
cmd.Connection = con;
da = new System.Data.SqlServerCe.SqlCeDataAdapter(cmd.CommandText, cmd.Connection);
try
{
da.Fill(ds1, "upnp_daily");
}
catch (Exception e2)
{
MessageBox.Show("Error 7: " + e2.ToString());
}
MessageBox.Show("Connection Open");
MaxRows = ds1.Tables["upnp_daily"].Rows.Count;
MessageBox.Show("No of rows in DataSet = " + MaxRows.ToString());
}
private void updateDS()
{
DataRow dRow = ds1.Tables["upnp_daily"].NewRow();
dRow[1] = dateTimeStmp;
dRow[2] = fIrrad;
dRow[3] = fDPM_A; dRow[4] = fPR_A;
dRow[5] = fDPM_B; dRow[6] = fPR_B;
dRow[7] = fDPM_C; dRow[8] = fPR_C;
dRow[9] = fDPM_D; dRow[10] = fPR_D;
dRow[11] = fTotal; dRow[12] = fPR;
ds1.Tables["upnp_daily"].Rows.Add(dRow);
UpdateDB();
MaxRows++;
inc = MaxRows - 1;
MessageBox.Show("Record is saved in Dataset.");
}
private void UpdateDB()
{
System.Data.SqlServerCe.SqlCeCommandBuilder cb;
cb = new System.Data.SqlServerCe.SqlCeCommandBuilder(da);
cb.DataAdapter.Update(ds1.Tables["upnp_daily"]);
}
private void closeSQLserver()
{
con.Close();
}
|
|
|
|
|
Change the Build property on your database so that it's set to Update if newer, rather than Update always.
|
|
|
|
|
So there is nothing wrong with my code above? The error is one parameter missing at da.Fill( ) and I couldn't spot where exactly go wrong
|
|
|
|
|
Hi,
Even when I create sql database with the latest version, there is still this compatibility error, and so I added UpgradeDatabasewithCaseSensitive() as mentioned in http://msdn.microsoft.com/en-us/library/bb896160(v=vs.100).aspx in my form.
After I debug and compile my program for the first time, the program runs fine subsequently without UpgradeDatabasewithCaseSensitive() anymore. But after some undefined time, when I debug and compile again, the compatibility error appears again and all the data I have saved so far in my database is all gone.
I decided to switch on and off visual studio window and run the program again. Sometimes, I can run the program without needing UpgradeDatabasewithCaseSensitive(). Sometimes, I need to include it. I decided to switch on and off my laptop and run the program again. The problem still remains. The program runs sometimes without needing to upgrade and sometimes needs to upgrade (then all the data is gone).
Why doesn't the data remain in database? Can someone help please? I'm still a novice with c#. Below is my code.
STS
//code
System.Data.SqlServerCe.SqlCeConnection con;
System.Data.SqlServerCe.SqlCeDataAdapter da;
DataSet ds1;
private void connectSQLserver()
{
//Connecting to SQL Server Express Database
con = new System.Data.SqlServerCe.SqlCeConnection();
con.ConnectionString = @"Data Source=C:\Visual Studio 2010\Projects\Form\Form\bin\Debug\database.sdf";
UpgradeDatabasewithCaseSensitive(); //update only once first time
try
{
con.Open();
}
catch (Exception e)
{
MessageBox.Show("Error : " + e.ToString());
}
ds1 = new DataSet();
string sql = "SELECT * From upnp_daily_energy";
da = new System.Data.SqlServerCe.SqlCeDataAdapter(sql, con);
try //run the query
{
da.Fill(ds1, "upnp_daily"); //run the query
}
catch (Exception e2)
{
MessageBox.Show("Error : " + e2.ToString());
}
MessageBox.Show("Connection Open"); //<<---DEBUG
}
public static void UpgradeDatabasewithCaseSensitive()
{
// Default case-insentive connection string.
// Note that .sdf is an old 3.1 version database.
string connStringCI = "Data Source= upnp_database.sdf; LCID= 1033";
// Set "Case Sensitive" to true to change the collation from CI to CS.
string connStringCS = "Data Source= upnp_database.sdf; LCID= 1033; Case Sensitive=true";
SqlCeEngine engine = new SqlCeEngine(connStringCI);
// The collation of the database will be case sensitive because of
// the new connection string used by the Upgrade method.
try
{
engine.Upgrade(connStringCS);
}
catch (Exception ex3)
{
MessageBox.Show("Error 2: " + ex3.ToString());
}
SqlCeConnection conn = null;
conn = new SqlCeConnection(connStringCI);
conn.Open();
//Retrieve the connection string information - notice the 'Case Sensitive' value.
List<keyvaluepair<string, string="">> dbinfo = conn.GetDatabaseInfo();
Console.WriteLine("\nGetDatabaseInfo() results:");
foreach (KeyValuePair<string, string=""> kvp in dbinfo)
{
Console.WriteLine(kvp);
}
}
modified 20-Nov-13 2:42am.
|
|
|
|
|
How to upload a file on pulic folder in SkyDrive using C# code. Please help me out.
please suggest through example.
Thank you.
|
|
|
|
|
|
How to Read E-Mail and the Attachments using C#.
the mail maybe gmail or yahoomail or hot mail or webmail
|
|
|
|
|
|
There are several articles here on CodeProject that demonstrate reading e-mail, with, or without, attachments. Just search.
"What Turing gave us for the first time (and without Turing you just couldn't do any of this) is he gave us a way of thinking about and taking seriously and thinking in a disciplined way about phenomena that have, as I like to say, trillions of moving parts.
Until the late 20th century, nobody knew how to take seriously a machine with a trillion moving parts. It's just mind-boggling." Daniel C. Dennett
|
|
|
|
|
pls help me with this error
heres my code:
if (capture == null)
{
try
{
Image<Bgr, byte> capture1 = new Image<Bgr, byte>("1.GIF");
VideoWriter v = new VideoWriter("output.mp4",-1, 1, 1920, 1080, true);
v.WriteFrame(capture1);
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
#endregion
if (capture != null)
{
if (captureInProgress)
{
button2.Text = "Start!";
Application.Idle -= ProcessFrame;
}
else
{
button2.Text = "Stop";
Application.Idle += ProcessFrame;
}
captureInProgress = !captureInProgress;
}
trim2010
|
|
|
|