|
Hi
I presume you have a DataSet to transfer the data? Well, just look in there
"There are no stupid question's, just stupid people."
|
|
|
|
|
I've been looking in there through the debugger as well as in the DataTable and DataColumn and I don't see anything that would tell me the type or the length of the individual columns. Do you know of something more specific?
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Your dataset contains the mapping from SQL types to .NET types, if you dont have a dataset (which I doubt), just get one of the data adapters auto generate u one. Then double click that file (the .xsd file) and it will show the equivalent SQL types. For the length of each type (of each parameter), that too get auto generated if you are using stored procedures.
Hope this helps
"There are no stupid question's, just stupid people."
|
|
|
|
|
You say that "Your dataset contains the mapping from SQL types to .NET types...". I do have a DataSet, I just don't know where this mapping is that you are referring to. What member of the DataSet contains this information? You understand that I want to obtain this info programmatically, right?
Thanks again.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
perlmunger wrote:
You understand that I want to obtain this info programmatically, right?
No, but i do now
<dataset instance="">.<tablename>.Columns["Usersorwhatever"].....oh damn I have no idea, where that takes place... You can find out the .NET types, so I assume the cast from SQL to .NET is auto, inserting values u need the SqlType and width though, so I'm not sure how this is done. I will look tomorrow, I need some desperate sleep
"There are no stupid question's, just stupid people."
|
|
|
|
|
I would avoid to use the dataset because at this point they have already done some type mapping (either CTS, or XSD).
Here is the code for retrieving the internal SQL Server data type for any database table columns :
DataTable oTable = new DataTable();
SqlDataAdapter oAdapter = new SqlDataAdapter("SELECT * FROM INFORMATION_SCHEMA.COLUMNS", m_oConnection);
This stores the result of the system query in oTable. Then you just need to lookup the rows of this table. Interesting columns are of course "COLUMN_NAME" and "DATA_TYPE".
If you have SQLServer installed, I guess this kind of things should be known by you a million times already, because you can see these things in the SQL Enterprise manager GUI.
How low can you go ? (MS rant)
|
|
|
|
|
I finally found a similar answer on google this morning. I am new to SQL Server, so I had no idea. Thanks for your help.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I'm not sure what is going on here, but I hope there's someone who knows why this happens. Basically, I have a base class and an inherited class, something like this:
public abstract class Base {}
public class Inherited : Base {}
I also have a class that populates inherited objects called ObjectBuilder. It is a singleton and it has a method called PopulateObject. Here is the code to do what I want:
Inherited i = new Inherited();
ObjectBuilder ob = ObjectBuilder.GetInstance();
ob.PopulateObject( ref i );
The problem is that the signature for PopulateObject takes a ref to Base. If I understand the is-a relationship properly, doing so should work and in fact, when I remove the 'ref' keyword from the declaration as well as implementation, it builds fine. It just won't work properly because it is at that point passing a copy (isn't it?). What is going on here? Why will it build without error when I pass a copy, but fails when I pass by reference?
Any help would be greatly appreciated.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Which error message is your compiler giving?
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
See below...
The best overloaded method match for 'DataNamespace.ObjectBuilder.PopulateObject( ref DataNamespace.Base)' has some invalid arguments
'Argument '1': cannot convert from 'ref DataNamespace.Inherited' to 'ref DataNamespace.Base'
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
You are infact passing by reference by default unless your base class is infact of a value-type!
"There are no stupid question's, just stupid people."
|
|
|
|
|
I went ahead and tried to run my app without the ref parameter and it worked--which led me to the same conclusion. I looked back at my Programming C# book (Oreilly) and sure enough, the example where he is using this is with value types. Oy!! People who think that C# and Java are the same are smoking crack. I like C# better because you can pass a value type by reference if you want to(in java you have to use the Integer, Double, etc. classes to do so). Thanks for your help.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
There was an obscure white paper I ran across once on the MSDN site which discussed the use of ByVal vs. Ref in application of VB.NET vs. C#.NET.
It basically stated that C#, by default, passes parameters as ref. So if you specify MyMethod(ref someParameter) what you are doing is passing a pointer to the pointer for the parameter. This could explain the illegal reference compile error if you are using the parameter as a parameter pointing to a data area within the caller, rather than a pointer pointing back to a pointer which points to the data area within the caller. gives me a headache just describing it.
---------------------------------------------
Once I thought I was wrong but I was happy to discover that was a mistake.
Condor
|
|
|
|
|
I know what you mean about a headache. It's not so bad once you get used to it, I suppose, but I'm used to C++ and trying to make the transition to C#. Probably a few more headaches along the way. I guess the rule of thumb with C# is if you think it's complicated, you're probably just making it so. Thanks for your help. I appreciate it.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Could be
It's one of the reasons why C++.NET could be considered superior (despite the rather hap-hazard managed extensions syntax) -- it forces you to box and unbox objects yourself, and think about whether they're value or reference types, and access them accordingly.
--
Paul
"I need the secure packaging of Jockeys. My boys need a house!"
- Kramer, in "The Chinese Woman" episode of Seinfeld
MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446
|
|
|
|
|
I have a float number like 32134(its size of file in bite).I want to divide it by 1000.So I do this:
f=12342;
f2=f/1000
I want to get 12.342 but it gives me 12. How can I get 12.342?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hi.
its the same as in C++
1000.0 is a double
1000.0f is a float
1000f is a float
1000 is an int
Therefore
f=12342;<br />
f2=f/1000.0f
Hope this helps
Pete
|
|
|
|
|
Mazy, This gives me 12.342, how are you doing it? Was your f2 defined as an int?
float f = 12342;
float f2;
f2 = f/1000;
Console.WriteLine(f2);
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Thank you both.I made some mistakes.Its OK now.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hi
I am facing a problem when darging and droping a user control. How can i Drag and Drop a user control physically. that is when draging and droping the control must go from one place to the other
|
|
|
|
|
Is there a way to count the number of subscriptions to a given event? We all know about the += operator to add a new subscription to an event and the -= to remove one. So, can you count the number of subscriptions, for example, a click event of a menu item:
this.mnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click1);
this.mnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click2);
this.mnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click3);
I would like something like this (I know this is not valid):
int nClickCount = this.mnuFileOpen.Click.Count;
or
int nClickCount = CountSubscriptions(this.mnuFileOpen.Click);
nClickCount would be 3.
Thanks in advance
Andy
|
|
|
|
|
In fact, you are using a multicast delegate instead of a single cast delegate (System.MulticastDelegate instead of System.Delegate).
The System.MulticastDelegate API provides what you need.
Namely, GetInvocationList(); returns the Delegate[] array.
How low can you go ? (MS rant)
|
|
|
|
|
OK. So, from the example I gave, what would I need to do exactly to get the count? I'm a bit unsure.
Thanks again
Andy
|
|
|
|
|
More info on delegate type is needed to provide full source code.
I guess this code will be helpful :
class App {
delegate String GetStatus();
static void Main() {
GetStatus getStatus = null;
getStatus += new GetStatus(new Light().SwitchPosition);
getStatus += new GetStatus(new Fan().Speed);
getStatus += new GetStatus(new Speaker().Volume);
Console.WriteLine(GetComponentStatusReport(getStatus));
}
static String GetComponentStatusReport(GetStatus status) {
if (status == null) return null;
StringBuilder report = new StringBuilder();
Delegate[] arrayOfDelegates = status.GetInvocationList();
foreach (GetStatus getStatus in arrayOfDelegates) {
try {
report.Append(getStatus() + "\r\n\r\n");
}
catch (Exception e) {
Object component = getStatus.Target;
report.Append("Failed to get status from " +
((component == null) ? "" : component.GetType() + ".") +
getStatus.Method.Name +
"\r\n Error: " + e.Message + "\r\n\r\n");
}
}
return report.ToString();
}
}
How low can you go ? (MS rant)
|
|
|
|
|
I have a simple c# component which actually read the Excel Spreedsheet and store the contain into an array.
I'm referencing the Microsoft Excel 9.0 Object Library in my C# componenet.
It work OK when i using the C# sample program to call the component but it not able to read the excel file when i using the ASP.NET.
The error message "Access is denied" is show when i using the ASP.NET to call the component.
I have try to open and read the same excel file only using ASP.NET by using SELECT * FROM [SHEET1] and able to read the Spreedsheet contains.
It open and read the file successfully. When i bind the dataSet from the Excel spreadsheet to the DataGrid, it show all the contains in the DataGrid.
But it not show the complete DataSet contain when i try to print the dataset contain in xml format using
Response.write(ds.getxml()).
Have anyone of you have experience this problem before? please advice. Thanks.
Regard
LSL
|
|
|
|