|
|
Use a parameterised query, then you don't have to format the values yourself:
SQL = "INSERT INTO sent (Date, Message) VALUES (@Date, @Message)";
Now add parameter objects for @Date and @Message to the command object.
If you really want to format the values yourself, you use # around dates in Access, you have to format the date in a way that the database understands (ISO 8601 is an unambigous format), and you have to encode the apostrophes in the string values:
SQL = "INSERT INTO sent (Date, Message) VALUES (#" + DateTime.Today.ToString("yyyy-MM-dd") + "#, '" + strMessage.Replace("'", "''") + "')";
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi there,
Since the final version will be coded in C# I thought I could just post it here. Any answers on others languages would be great too though.
I'm trying to find an algorithm that will calculate how much two Strings differ from eachother. For example, giving a score from 0-100 based on how much they are alike. I did come across the Levenshtein algorithm, but that wasn't realy what I'm looking for.
For example:
Comparing "markAdress" with "adressMark" should return a high score, since they are much alike.
Kind regards,
~Sph
|
|
|
|
|
Hi y'all,
I'm working with a two-dimensional array and i need to randomly select any element from the array at any given time. Is this possible?
Second, from an array of strings, is it possible to randomly select a string value like the System.Random class?
Thanks in advance,
Obinna from Nigeria.
//obinnaaj Eof
|
|
|
|
|
In first case just generate two random numbers which are not more then the dimension of the array and use them for indexes to access an element of the array.
In the second case generate a random number not more then the length of the array and access an element with that index
|
|
|
|
|
hi
i have a reportViewer in my form and a report in reportDesigner named 'Report1.rdlc'.
in my report, i define a parameter that has these properties :
Name = Report_Parameter_0
Data type = String
Promt = 11111111111111
Allow blank value = true
Null = true
and add a textBox to my report in reportDesigner with following properties :
Name = textbox5
Value = Parameters!Report_Parameter_0.Value
and in my form load event that show report i wrote this code to send my value to 'Report_Parameter_0' programmatically :
try
{
this.v_customerOrderCountTableAdapter.Fill(this.NorthwindDataSet.v_customerOrderCount);
Microsoft.Reporting.WinForms.ReportParameter rp = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_0", "Param From Code");
this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { rp });
this.reportViewer1.RefreshReport();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
with above information, in runTime, i prospected that 'textbox5' have 'Param From Code' value, but have
'Parameters!Report_Parameter_0.Value' yet.
where does problem and how to send value to reportParameter correctly ?
thanks
|
|
|
|
|
ServerReport.SetParameters Method
List<ReportParameter> paramList = new List<ReportParameter>();<br />
<br />
paramList.Add(new ReportParameter("EmpID", "288", false));<br />
paramList.Add(new ReportParameter("ReportMonth", "12", false));<br />
paramList.Add(new ReportParameter("ReportYear", "2003", false));<br />
<br />
this.reportViewer1.ServerReport.SetParameters(paramList); ??
|
|
|
|
|
I require to disable/enable check box in a property grid dynamically at runtime using C# .NET.
I was able to to disable/enable the Check box at runtime. But the problem is If I enable check box dynamically I am no longer able to select the check box. I am using TypeConvertor and UITypeEditor together to disable/enable the check box at runtime.
If I do not use TypeConvertor with UITypeEditor then I am able to select the check box.
Can anyone faced this problem ?
I am using the following Code piece:
[TypeConverter(typeof(myConverter))]
[Editor(typeof(CheckBoxInPropertyGridEditorCapex), typeof(System.Drawing.Design.UITypeEditor))]
public bool ValidForCapex
{
get { return validForCapex; }
set { validForCapex = value; }
}
public class CheckBoxInPropertyGridEditorCapex : UITypeEditor
{
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return true;
}
public override void PaintValue(PaintValueEventArgs e)
{
ControlPaint.DrawCheckBox(e.Graphics, e.Bounds, ((GeneralDimensionClass)e.Context.Instance).validForCapex ? ButtonState.Checked : ButtonState.Normal);
}
}
public class myConverter : StringConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (ValidForCapexRead == true)
{
return false;
}
return base.CanConvertFrom(context, sourceType);
}
public override bool CanConvertTo(ITypeDescriptorContext context,
System.Type destinationType)
{
return base.CanConvertTo(context, destinationType);
}
}
Rajan
|
|
|
|
|
please someone help me. I need to write codes for how may days til christmax.
|
|
|
|
|
There is a complex formula for calculating that. It isn't hard to implement, just use your best friend. GOOGLE.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
DateTime xmas = new DateTime(2007, 12, 25);
Console.WriteLine(xmas.Subtract(DateTime.Today).Days); This is simple enough since all you need to do is basic date arithmetic and subtract today's date from 12/25/2007.
|
|
|
|
|
hey thanks so much guy that was very helpful. I am really new to programming. thanks again.
|
|
|
|
|
Congrats, you just did this guys homework.
|
|
|
|
|
Oh well...every once in a while a homework question will slip by me. If it was homework, he still won't have an easy time passing the class if he's stumped on something that simple.
|
|
|
|
|
I want to check whether the user is able to connect to a host specified with given user name and password or not in network.
I used NetWorkCredential class but with that I am unable to validate the user name and password.
Can any one suggest me a way to do the same.
Thanks in advance.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Why am I getting this error? My stored procedure is returning the value of an int column...
try {
SqlDataReader r = run_sql_reader(sql);
if (r.Read()) {
LB_CO_record_number.Text = (r.GetInt32(0)).ToString(); //***exception here
}
r.Close();
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
Visual Studio is not telling me what is trying to be casted to what else, so I can't figure out which thing is causing the error. I do this kind of thing all the time and I've never gotten this error.
"Quality Software since 1983!"http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.
|
|
|
|
|
Mmmmkay... I figured it out. My proc was for some reason not returning an int column. I don't know what it was returning, but using "convert" on the value before sending it back fixed the problem. Crazy computers
|
|
|
|
|
By any chance did you get a NULL returned from the database. Attempting to convert NULL to another might succumb with System.InvalidCastException: The specified cast is invalid .
Vasudevan Deepak Kumar
Personal Homepage
Tech Gossips
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
No it returns a number, which I verified, but it's good to know that. I'll add some code to check for that. Thanks!
|
|
|
|
|
How to code in C# calling the stored procedure with no parameter.
Inside my stored procedure is just to delete specified column.
thanks,
******************************
I just want to
know everything
|
|
|
|
|
Please post the code that you tried and is not working. It should be a simple call...
|
|
|
|
|
Create an instance of SqlCommand class and set command text to the name of the stored procedure. Don't forget to set the type of the command to. You can then execute it by calling ExecuteNonQuery() method
|
|
|
|
|
following namespace not found :-
Microsoft.Office.Interop.Excel.ApplicationClass
Gaurav
|
|
|
|
|
Make sure you have added the assembly in your references in your project. Otherwise, please post more information.
|
|
|
|
|
creating and saving excel work sheet at runtime
Gaurav
|
|
|
|