|
Well, I certainly was able to replicate it.
In my derived class for OleDb, I have added:
protected override System.Data.IDbDataParameter
AddParameter
(
string Name
,
object Value
)
{
System.Data.OleDb.OleDbParameter result =
(System.Data.OleDb.OleDbParameter) base.AddParameter ( Name , Value ) ;
if ( Value is System.DateTime )
{
result.OleDbType = System.Data.OleDb.OleDbType.Date ;
}
return ( result ) ;
}
Which solved the immediate problem, but I suppose there are others out there waiting to pounce.
|
|
|
|
|
Thanks for the confirmation and the suggestions, I'm good now.
|
|
|
|
|
Luc Pattyn wrote: I'm good now
Don't sell yourself short.
|
|
|
|
|
Since you asked, here is my next obstacle: I have a legacy Access database I want to convert to something more modern, probably SQLServer Express. The built-in "Upgrade Wizard" produced a working database, except for the primary keys: all fields of type "Autonumber" became regular integer fields, without "Identity ON". I know I could convert each table individually, adding a column, marking it identity, then force it to accept the existing values, finally removing and renaming columns. But that is so messy and cumbersome. Do you have any suggestions? or did I miss something?
TIA.
|
|
|
|
|
I dunno. I avoid wizards; I prefer to maintain control. On the other hand, the closest I've come to that was writing an app to create a clone of an Ingres database in SQL Server -- which had no keys and hardly any indices, so I didn't bother copying them.
Of course, I also avoid "Autonumber" fields, so you'll get little sympathy from me.
Here's what I currently have for doing that sort of thing:
protected virtual System.Collections.Generic.Dictionary<System.Type,System.String> TypeMap { get ; set ; }
...
public virtual int
CreateTable
(
string TableName
,
System.Data.IDataReader SchemaSource
)
{
return ( this.CreateTable ( TableName , SchemaSource.GetSchemaTable() ) ) ;
}
public virtual int
CreateTable
(
string TableName
,
System.Data.DataTable SchemaSource
)
{
if ( this.TypeMap == null )
{
throw ( new System.InvalidProgramException ( "You can't translate without a TypeMap" ) ) ;
}
System.Text.StringBuilder cmd = new System.Text.StringBuilder() ;
cmd.AppendFormat ( "CREATE TABLE [{0}] ( " , TableName ) ;
foreach
(
System.Data.DataRow col
in
SchemaSource.Rows
)
{
if ( !this.TypeMap.ContainsKey ( (System.Type) col [ "DataType" ] ) )
{
throw ( new System.InvalidProgramException
( "The TypeMap doesn't contain type " + col [ "DataType" ].ToString() ) ) ;
}
cmd.AppendFormat
(
this.TypeMap [ (System.Type) col [ "DataType" ] ]
,
col [ "ColumnName" ]
,
col [ "ColumnSize" ]
,
col [ "NumericPrecision" ]
,
col [ "NumericScale" ]
,
(bool) col [ "AllowDBNull" ]?" NULL ":" NOT NULL "
) ;
cmd.Append ( " , " ) ;
}
cmd.Replace ( "," , ")" , cmd.Length - 2 , 1 ) ;
return ( this.ExecuteNonQuery ( cmd.ToString() ) ) ;
}
I know I've used this method, but only to clone tables from SQL Server to Access, so I'm unsure if it will work the other way.
Here's the TypeMap I have for Access:
typemap = new System.Collections.Generic.Dictionary<System.Type,System.String>() ;
typemap [ typeof(System.String) ] = " [{0}] TEXT({1}) " ;
typemap [ typeof(System.Boolean) ] = " [{0}] YESNO " ;
typemap [ typeof(System.Int32) ] = " [{0}] INT " ;
typemap [ typeof(System.DateTime) ] = " [{0}] DATETIME " ;
typemap [ typeof(System.Guid) ] = " [{0}] UNIQUEIDENTIFIER " ;
I hope it helps, or at least makes you laugh. I picture Hercule ROTFLMAOing.
modified on Thursday, August 4, 2011 12:52 AM
|
|
|
|
|
|
Hello,
I am trying to setup a RegEx expresion to check a text box for numeric values but also have the possibility to have a < or > symbol. For example the input could be 25.1 or > 20 or < 50, etc. How can I allow for the < or > symbol?
Thanks
|
|
|
|
|
There is a Regular Expressions forum.
How about something as simple as: ^(\s|\d|\.|<|>)*$ (not tested).
|
|
|
|
|
If you don't want to allow any spaces, try ^[<>]?\d+\.?\d*$ That scans as
^ beginning of string
[<>]? < or >, zero or one times
\d+ one or more digits
\.? zero or one decimal points
\d* zero or more digits
$ end of string
Ran a few cases past Expresso and they look OK. If you want to allow scientific notation, etc, grab the examples from Expresso (see our Free Tools forum for a link) and splice in the [<>]? bit. This one won't allow .3 or >.6 - it requires a digit before a decimal point, but a few minutes with Expresso will get you anywhere.
Cheers,
Peter
ps As the previous answer indicated, the Regular Expressions forum would be more appropriate next time.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Thanks everyone for the suggestions. They have helped get started but the criteria has changed. I now need to support the following conditions:
1. a value of N/A only in the field => N/A
2. a numeric value with decimal points => 24.231
3. a numeric value that can begin with < character => < 12.1, or < .5
4. a numeric value that can begin with > character => > 27.2, or > .5
|
|
|
|
|
Before we go any further, let's settle on the spec.
Is N/A required to be uppercase? Are any or all of n/a N/a n/A acceptable?
From your example, .12 is OK. What about 13. ?
Is an integer value like 123 (no decimal point) allowed?
Are there limits on the number of digits (total/before/after the decimal point)?
Your answers to these questions do not affect the solvability of the problem (the existence of a suitable regex), but they do affect the solution (the value of the regex).
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Basically, I have a field that either can take an integer value up to 3 digits or a decimal value with up to 2 decimal places. I change the mask in code before the screen is displayed. Below is an example of the existing masks.
TextBox1.Mask ='\d?\d?\d?';
OR
TextBox1.Mask = '\d+.\d?\d?';
Now, I need to have the integer mask have the ability to accept a <, > or N/A as well as to have the decimal mask do the same. I need it in two masks because I dont want certain fields to be able to enter decimal values and other fields to have the ability.
I also can set the textbox to foce upper case for (N/A) and set a max length if needed.
|
|
|
|
|
OK. Here are a couple:
*note* these are regexes, which may or may not be suitable for use directly in a maskedit control mask field.
integer, 1 - 3 digits with N/A < >
^(N/A)|([<>]?\d{1,3})$
float, 0 - 2 decimal places, with the same extras
^(N/A)|([<>]?\d+\.\d{0,2})$
This one requires at least one digit before the decimal point. If you want to allow .12 change the + in the middle to * .
Following the "teach a man to fish" philosophy, I strongly recommend you get yourself a copy of the free tool Expresso[^]
(I have no connection to Ultrapico other than as a very satisfied user.)
Cheers,
Peter
[edit] added *note* [/edit]
Software rusts. Simon Stephenson, ca 1994.
modified on Wednesday, August 3, 2011 9:17 PM
|
|
|
|
|
Thanks for the assistance and thanks for the link to Expresso.
|
|
|
|
|
hi to every one
i try to use ozf2 or ozf3 file in my application
is there any way to use this files with C#?
i know the ozf file is indexed image file with it we can load part of image in memory
but how can do that?
i want use this image for GPS map file
if can't do this is there any other way to load GPS map?
|
|
|
|
|
mohsen-unique wrote: is there any way to use this files with C#?
Yes, always. A file is just a bunch of bytes, nothing stops you from using them.
I have no idea what a ozf2 files looks like inside though.
|
|
|
|
|
the ozf2 file is a kind of file for map that used in oziexplorer program.this program in gps tracking
for more information about oziexplorer go to http://www.oziexplorer3.com/[^]
|
|
|
|
|
Ok, I can't find any useful information there though - such as the structure of the file.
|
|
|
|
|
i have same problem i can't found any information about structure of the file
|
|
|
|
|
So what are you trying to do? Crack open the files so that you can extract the underlying maps?
|
|
|
|
|
na i want use the ozf file for my application that load map file and show the location of user from GPS device
|
|
|
|
|
It looks like this file format was invented by the author for his application. I doubt you'll find it readily available anywhere I'm afraid.
|
|
|
|
|
|
hi
i have this code for update datetime fileds in access using params
SQL = "update ConfTbl set D_from = @MyFrom , D_to = @MyTo where Code = " + Convert.ToInt32(TmpCode1) + "";
OleDbCommand Cmd = Conn.CreateCommand();
OleDbParameter dateparam1 = Cmd.Parameters.AddWithValue("@MyFrom", DbType.DateTime);
dateparam1.Value = dt_From.Value;
OleDbParameter dateparam2 = Cmd.Parameters.AddWithValue("@MyTo", DbType.DateTime);
dateparam2.Value = dt_To.Value;
Cmd.CommandText = SQL;
Cmd.ExecuteNonQuery();
how to change this for run query that find between two dates ?
somthing like: `select * from ConfTbl where Tdate >= #MyFrom# and Tdate <= #MyTo#`
thanks in advance
|
|
|
|