46 3760
Have you set your editor setting in the control panel (of tsdn) as enhanced mode?
Need a moderator / admin to change your code...cant follow it. Once thats done decypering it will be easier :D unless u plan to manually remove all the size and color tags
I would have a go at fixing it, but I have no idea what all the <summary> tags mean.
I would have a go at fixing it, but I have no idea what all the <summary> tags mean.
Arent those xml comments?
except the '' will have to be removed and replaced by ///
Arent those xml comments?
except the '' will have to be removed and replaced by ///
Since I have no idea what you mean, I'd better not touch it.
it should look fine now i did it in notepad and removed all the tags
oh those tags, forget those they are in the comments. i am just focusing on the lines that use TypeCode as a datatype it is a vb .net data type and i have no idea how to replace it in C#
C#:
public TypeCode DataType
VB .NET:
Public Property DataType() As TypeCode
The VB.Net one is fine it works but I want to use C# so i used a converter and it gave me the above... however TypeCode is not recognized by the C# compiler so what do i replace it with????
typecode is not a datatype, its an enumerator
Is TypeCode used to pass in a a DateType? Like in the days of c++ myclass<T> kinda deal?
Just try using Type
Is TypeCode used to pass in a a DateType? Like in the days of c++ myclass<T> kinda deal?
Just try using Type
See told you I was a newbie and yes i believe it is used to pass in a datatype.
Well I'm not sure hot to fix this: -
public class TextFieldEnumerator : TypeCode, System.Collections.IEnumerator
-
But this would be like: -
public System.Type DataType
-
{
-
get
-
{
-
return _dataType;
-
}
-
set
-
{
-
_dataType = value;
-
}
-
}
-
OK how could we write this:
OK how could we write this:
VB .NET
Public Class TextFieldEnumerator
Inherits Object
Implements System.Collections.IEnumerator
Private iEnBase As System.Collections.IEnumerator
Private iEnLocal As System.Collections.IEnumerable
in C#??
this didn't work? -
public class TextFieldEnumerator : object, System.Collections.IEnumerator
-
{
-
private System.Collections.IEnumerator iEnBase;
-
private System.Collections.IEnumerable iEnLocal;
-
}
-
Thanks Plater,
leaves me with this error in at runtime
Error 1 'TextFieldCollection.TextFieldEnumerator' does not implement interface member 'System.Collections.IEnumerator.Current'. 'TextFieldCollection.TextFieldEnumerator.Current' is either static, not public, or has the wrong return type. C:\Users\Dale\Downloads\Documents\Visual Studio 2005\Projects\CIMImporter\CIMImporter\TextFieldPar ser.cs 649 17 CIMImporter
But it fixed the other one's lol... getting closer.
Thanks Plater,
leaves me with this error in at runtime
Error 1 'TextFieldCollection.TextFieldEnumerator' does not implement interface member 'System.Collections.IEnumerator.Current'. 'TextFieldCollection.TextFieldEnumerator.Current' is either static, not public, or has the wrong return type. C:\Users\Dale\Downloads\Documents\Visual Studio 2005\Projects\CIMImporter\CIMImporter\TextFieldPar ser.cs 649 17 CIMImporter
But it fixed the other one's lol... getting closer.
Implementing an interface is the same as signing a contract which says that "I swear to implement all the methods defined in that interface otherwise I'm going to declare that I'm abstract"
Thanks Plater you have been super helpful and using someone elses code sure makes learning a little easier... I was confused by that error because of this..
object System_Collections_IEnumerator_Current
{
get
{
return iEnBase.Current;
}
}
aparently the translator I used doesn't speak a very good c# lol it should have been
object System.Collections.IEnumerator.Current
{
get
{
return iEnBase.Current;
}
}
I looked a little harder because I knew i had the implementation there lol.
Plater I have another bump, in vb.net i have the following
Imports System.Data
Imports System.Data.SqlClient
Public Class Order
Inherits DataServiceBase
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal trans As IDbTransaction)
MyBase.New(trans)
End Sub
Public Function InsertOrder(ByVal xmlStr As String) As Integer
Dim OrderNo As Integer = -1
Dim param As SqlParameter = CreateParameter("@lNewOrderID", SqlDbType.Int, OrderNo, ParameterDirection.Output)
ExecuteNonQuery("sp_TracksOrders_Import", CreateParameter("@xsDetails", SqlDbType.VarChar, xmlStr, 6000), _
param)
OrderNo = param.Value
Return OrderNo
End Function
End Class
The line that is giving me trouble in the conversion is
------ Inherits DataServiceBase
The c# code comes out like this but it doesn't recognize DataServiceBAse
using System.Data;
using System.Data.SqlClient;
public class Order : DataServiceBase
{
public Order()
{
}
public Order(IDbTransaction trans)
:
base(trans)
{
}
public int InsertOrder(string xmlStr)
{
int OrderNo = -1;
SqlParameter param = CreateParameter("@lNewOrderID", SqlDbType.Int, OrderNo, ParameterDirection.Output);
ExecuteNonQuery("sp_TracksOrders_Import", CreateParameter("@xsDetails", SqlDbType.VarChar, xmlStr, 6000), param);
OrderNo = param.Value;
return OrderNo;
}
}
ignore above i was missing a class.
Can you help me understand what they are trying to do with the following declaration:
Private _delimiter As Char = Convert.ToChar(",")
it works fine in vb.net but when i try to convert it in C# it tells me it cannont convert to type char from type char.
I don't know why the go the long way in that statement. "." is a string containing a period '.' is character that is a period. Double-quotes are used for strings, single-quotes for characters.
The end result of that statement would be this:
private char _deliminator = '.';
I don't know why the go the long way in that statement. "." is a string containing a period '.' is character that is a period. Double-quotes are used for strings, single-quotes for characters.
The end result of that statement would be this:
private char _deliminator = '.';
Your kidding me all that nonsense to declare and set a variable?
oh umm that might be a comma and not a period inside there. My font is really small and I can't tell the difference.
Thanks I knew what you meant....
How about this
DataFile.TextFields.Add(new TextField(FieldName, TypeCode.Int32, Quoted));
This is what the translator shot back but it doesn't like the Typecode.Int32 and I tried to investicate the System.Type but that didn't work...
Any thoughts?
Thank God for you amazing people out here for us newbies to sap the knowledge out of!!!
Maybe:
DataFile.TextFields.Add(new TextField(FieldName, Typeof(Int32), Quoted));
Yes sir seemed to like that but now it is grumbling about DataFile I looked it up and the namespace is Namespace: Microsoft.SqlServer.Management.Smo Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
I tried to add it:
Using Microsoft.SqlServer. (only option is Server)
You probably need to add a reference to the .dll -> microsoft.sqlserver.smo.dll
Go to references and Add and then look for it, it's under the .NET tab, you would search by it's namespace name. I found it in mine at least.
Ah see I learned something new today, thank-you so much for your patience. However, I must have the wrong one because it doesn't contain any of the methods the old code is using lol.
Ok another vb convertion messup....
if (!(input[x]==null)) <---------------
where input is a string array ...... ref string input[]
it keeps telling me it is a variable in the if statement used as a method, i understand what it is doing however i am not sure how to correct the implementation.
What is the VB code and what is the proposed C# code?
if (!(input[x]==null))
would be more likely written as:
if (input[x]!=null)
provided that input is an array:
<sometype>[] input = new <sometype>[<size>];
[font=Arial]Below is another issue, basically everything i can work with except the [/font]
The Dim statement I am not sure what it is doing with rawFields() is this not a method of runction... it is pulled from the Utilities.Text.Parsing namespace...
[font=Arial] Private Function GetFieldArray(ByVal fileRecord As String) As Array
Dim fields As Array = Nothing
Select Case Me.FileType
Case FileFormat.Delimited
' split the fields
Dim rawFields() As String = fileRecord.Split(Convert.ToChar(Me.Delimiter))
' recombine any with quotes
RecombineQuotedFields(rawFields)
' remove the extra elements
ExtractNullArrayElements(rawFields, fields)
Case FileFormat.FixedWidth
Dim rawFields As New ArrayList
Dim mark As Int32 = 0
For x As Int32 = 0 To _textFields.Count - 1
' extract the value and move the book mark
rawFields.add(fileRecord.Substring(mark, _textFields(x).Length))
mark += _textFields(x).Length
Next[/font]
[font=Arial] fields = rawfields.ToArray
Case Else
Throw New ApplicationException("The specified FileType is not valid.")
End Select
Return fields
End Function[/font]
I think there were some types on that (you had two objects called rawFields and no object called _textFields) -
private Array GetFieldArray(string fileRecord)
-
{
-
Array fields = null;
-
switch (this.FileType)
-
{
-
case FileFormat.Delimited:
-
// split the fields
-
string[] _textFields= fileRecord.Split(Convert.ToChar(this.Delimiter));
-
// recombine any with quotes
-
RecombineQuotedFields(rawFields);
-
// remove the extra elements
-
ExtractNullArrayElements(rawFields, fields);
-
break;
-
case FileFormat.FixedWidth:
-
ArrayList rawFields = new ArrayList();
-
Int32 mark = 0;
-
for (Int32 x = 0; x <= _textFields.Count - 1; x++)
-
{
-
// extract the value and move the book mark
-
rawFields.add(fileRecord.Substring(mark, _textFields[x].Length));
-
mark += _textFields[x].Length;
-
}
-
-
fields = rawfields.ToArray();
-
break;
-
default:
-
throw new ApplicationException("The specified FileType is not valid.");
-
break;
-
}
-
return fields;
-
}
-
One more issue I borrowed some files from another application and brought them inhouse under the same namespace (Good Idea? Bad Idea? not sure )
but regardless I have everything working except ......
TextFieldParser tfp;
//string filePath = Path.Combine(Path.GetDirectoryName(Application.Exe cutablePath), "Delimited.txt");
string filepath = myFilePath;
tfp = new TextFieldParser(myFilePath);
TextFieldCollection fields = new TextFieldCollection();
fields.Add(new TextField("Station", TypeCode.String, true));
fields.Add(new TextField("Reference", TypeCode.String, true));
fields.Add(new TextField("Name", TypeCode.String, true));
fields.Add(new TextField("Address 1", TypeCode.String, true));
fields.Add(new TextField("Adress 2", TypeCode.String, true));
fields.Add(new TextField("City", TypeCode.String, true));
fields.Add(new TextField("ST", TypeCode.String, true));
fields.Add(new TextField("ZIP", TypeCode.Int32));
fields.Add(new TextField("PH", TypeCode.Int32));
fields.Add(new TextField("Alt. PH", TypeCode.Int32));
fields.Add(new TextField("Waybill", TypeCode.String, true));
fields.Add(new TextField("Notes 1", TypeCode.String, true));
fields.Add(new TextField("Notes 2", TypeCode.String, true));
fields.Add(new TextField("Date", TypeCode.String, true));
tfp.TextFields = fields;
[BOLD] tfp.RecordFailed += new RecordFailedHandler(tfp_RecordFailed); [/BOLD]
This line throws an error no matter where it is daying "does not exist in current context" should i change the namespace back to the orginal and just include it with the using clause or is there a way to fix this as is???
-
tfp.RecordFailed += new RecordFailedHandler(tfp_RecordFailed);
-
Is how you attach event handlers. This is looking for the function called "tfp_RecordFailed" so it can use it for the RecordFailed event.
You will need to copy that function over as well.
Thanks I am learning alot with this little project of mine,
one more question in c# what is the best way to get the ascii value of a char(x)
Maybe I am thinking to fast but this should work: -
char mychar='x';
-
int asciivalue=(int)mychar;
-
[font=Arial]
Orginal VB.NET
Dim OrderNo As Integer = -1
Dim param As SqlParameter = CreateParameter("@lNewOrderID", SqlDbType.Int, OrderNo, ParameterDirection.Output)
ExecuteNonQuery("sp_TracksOrders_Import", CreateParameter("@xsDetails", SqlDbType.VarChar, xmlStr, 6000), _
param)
OrderNo = param.Value
Return OrderNo
VB.NET Function
Protected Sub ExecuteNonQuery(ByVal procName As String, ByVal ParamArray paramList() As IDataParameter)
Dim cmd As SqlCommand = Nothing
ExecuteNonQuery(cmd, procName, paramList)
End Sub
problem is when i convert this to C# it is not creating a parameter list and instead goes to another fucntion that is an overload with 3 parameters.
any thoughts how to redo this in c#.. basically i just need guidence on passing it with a parameter list
i.e.
ExecuteNonQuery("sp_TracksOrders_Import", parmeterlist??)[/font]
-
Protected Sub ExecuteNonQuery(ByVal procName As String, ByVal ParamArray paramList() As IDataParameter)
-
This should be like: -
protected void ExecuteNonQuery(string procName, params IDataParameter[] ParamArray)
-
Sorry I was referring to the function call.
ExecuteNonQuery("sp_TracksOrders_Import", CreateParameter("@xsDetails", SqlDbType.VarChar, xmlStr, 6000), _
param)
This comes from a different class calling the ExecuteNonQuerey as you described above but as you can see it has or at least it thinks it has 3 parameters instead of a string and a parameter list...
this ends up going straight to another overload function ExecuteNonQuery(cmd,procname,paramlist)
any thoughts?
This call: -
ExecuteNonQuery("sp_TracksOrders_Import", CreateParameter("@xsDetails", SqlDbType.VarChar, xmlStr, 6000), _param)
-
certainly seems like it fits into the (string, params[]) format to me? -
IDataParameter temp =CreateParameter("@xsDetails", SqlDbType.VarChar, xmlStr, 6000);
-
//somewhere else another IDataParameter is defined as "param"
-
ExecuteNonQuery("sp_TracksOrders_Import", temp,param);
-
That would call that ExecuteNonQuery(string, params IDataParameter[] myparams); function?
Thanks I found the problem because of that post, turns out the translator i used went and put
sqlparameter param = xxxxxx
and that was where the problem was arrising once i did it as above it corrected the problem now i have to troubleshoot the connection lol... it just never ends!!!
Ok one more question
I am new to event handling in C# and here is the situation
I believe I have all the parts, I have the deligate named recordhandler
the class with the ations to be taken
in the class that is calling it though (rasing the event so to speak) how to i tell it to call it.
if (RecordFound != null)
RecordFound(ref currentLineNumber, m_TextFieldSchema.TextFields);
m_CurrentLineNumber = currentLineNumber;
Record found in the try block is always null even though it is doing it's thing... how do i tell it before it gets to the if statement that a record was found?
Thanks
Dale.
[/size]
Are you wondering how to trigger your custom event?
Here's a slimmed down version of what I use for one of my things -
public delegate int RequestReceivedHandler(Socket RequestingSocket, Request TheRequest);
-
public class HttpListener
-
{
-
/// <summary>
-
/// The even for when HttpListener has received a request and read the data
-
/// </summary>
-
public event RequestReceivedHandler RequestReceived;
-
-
public void MockFire()
-
{
-
Socket mySocket;//fake
-
Request myRequest;//fake
-
int retval = RequestReceived(mySocket, myRequest);//fire the event
-
}
-
}
-
[size=2]tfp.RecordFound += new RecordFoundHandler([/size][size=2]tfp_RecordFound);[/size]
[size=2][/size]
[size=2]Thanks, that sample helped I was missing this from the originating class.
[/size]
Sign in to post your reply or Sign up for a free account.
Similar topics
by: johkar |
last post by:
In the below example I am using the following to try to match only the
unique MechanismText nodes within each Subscription node:
select="DeliveryPreferences/DeliveryPreference"
Right now, the...
|
by: Steve Brown |
last post by:
Hello all,
Is there a way to determine a variable's type at run-time? The reason
I'm asking is that i have code that looks like this:
template <class T>
Object::Object(int TypeCode, T* data)...
|
by: HairlipDog58 |
last post by:
Does anyone know if there is a built-in function for creating a Type from a
TypeCode?
Type t = somefunction(TypeCode.Int16);
|
by: crowl |
last post by:
I have a pocket pc project in c#.
From a textbox i have to verify if the input is numeric. I have found
in the msdn a sample like this: textbox1.numeric = true / false. But
this do not work in...
|
by: **Developer** |
last post by:
I do the following:
Select Case mDataType(mColumnToSort)
Case TypeCode.Int32
Result = CInt(xText).CompareTo(CInt(yText))
Case TypeCode.String
|
by: Demetri |
last post by:
I have a method that has a parameter that accepts a System.Type. How can I
test to see if the type passed is one of the numeric types?
I want to avoid a big if/else or switch statement if...
|
by: sck10 |
last post by:
Hello,
I am trying to determine if a value is NOT numeric in C#. How do you test
for "Not IsNumeric"?
protected void fvFunding_ItemInserting_Validate(object sender,
FormViewInsertEventArgs...
|
by: Neville Lang |
last post by:
Hi all,
I am having a memory blank at the moment. I have been writing in C# for a
number of years and now need to do something in VB.NET, so forgive me such a
primitive question.
In C#, I...
|
by: JRD |
last post by:
Greetings,
I would like to search down through the following xml string that is returned to my calling app via a webservice.
What I am trying to get is the following section from the xml string
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |