|
Carl, I will be reading the managed code part of my new SS2005 book tonight. I'll let you know if I can help tomorrow, but right now I am excited, but clueless.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What book do you have? I have "First Look at SQL Server 2005 For Developers", but imho, it's lacking information about writing managed code for SQL Server.
|
|
|
|
|
Pipe.Send takes another object, whose name escapes me now, which acts as a cursor. I have the same book.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
 SqlDataReader. Pretty useless if you ask me!
A SqlDataReader will pretty much only allow you to wrap another SQL statement.
Alazel Acheson (MS SQL Developer) has posted some GREAT code on the private Microsoft newsgroups. It allows me to return a dataset or datatable to the pipe. Here it is, for the record:
public static void SendDataSet( DataSet ds )<br />
{<br />
foreach( DataTable dt in ds.Tables )<br />
{<br />
SendDataTable( dt );<br />
}<br />
}<br />
<br />
<br />
public static void SendDataTable( DataTable dt )<br />
{<br />
bool[] coerceToString;
SqlMetaData[] metaData = ExtractDataTableColumnMetaData( dt, out coerceToString );<br />
<br />
SqlDataRecord record = new SqlDataRecord( metaData );<br />
SqlPipe pipe = SqlContext.Pipe;<br />
pipe.SendResultsStart( record );<br />
try {<br />
foreach( DataRow row in dt.Rows )<br />
{<br />
for( int index=0; index<record.FieldCount; index++ )<br />
{<br />
object value = row[ index ];<br />
if ( null != value && coerceToString[ index ] )<br />
value = value.ToString( );<br />
record.SetValue( index, value );<br />
}<br />
<br />
pipe.SendResultsRow( record );<br />
}<br />
}<br />
finally<br />
{<br />
pipe.SendResultsEnd( );<br />
}<br />
}<br />
<br />
private static SqlMetaData[] ExtractDataTableColumnMetaData( DataTable dt, out bool[] coerceToString )<br />
{<br />
SqlMetaData[] metaDataResult = new SqlMetaData[ dt.Columns.Count ];<br />
coerceToString = new bool[ dt.Columns.Count ];<br />
for( int index = 0; index < dt.Columns.Count; index++ )<br />
{<br />
DataColumn column = dt.Columns[ index ];<br />
metaDataResult[ index ] = SqlMetaDataFromColumn( column, out coerceToString[ index ] );<br />
}<br />
<br />
return metaDataResult;<br />
}<br />
<br />
private static Exception InvalidDataTypeCode( TypeCode code )<br />
{<br />
return new ArgumentException( "Invalid type: " + code );<br />
}<br />
<br />
private static Exception UnknownDataType( Type clrType )<br />
{<br />
return new ArgumentException( "Unknown type: " + clrType );<br />
}<br />
<br />
private static SqlMetaData SqlMetaDataFromColumn( DataColumn column, out bool coerceToString )<br />
{<br />
coerceToString = false;<br />
SqlMetaData smd = null;<br />
Type clrType = column.DataType;<br />
string name = column.ColumnName;<br />
switch ( Type.GetTypeCode( clrType ) )<br />
{<br />
case TypeCode.Boolean: smd = new SqlMetaData( name, SqlDbType.Bit ); break;<br />
case TypeCode.Byte: smd = new SqlMetaData( name, SqlDbType.TinyInt ); break;<br />
case TypeCode.Char: smd = new SqlMetaData( name, SqlDbType.NVarChar, 1 ); break;<br />
case TypeCode.DateTime: smd = new SqlMetaData( name, SqlDbType.DateTime ); break;<br />
case TypeCode.DBNull: throw InvalidDataTypeCode( TypeCode.DBNull );<br />
case TypeCode.Decimal: smd = new SqlMetaData( name, SqlDbType.Decimal, 18, 0 ); break;<br />
case TypeCode.Double: smd = new SqlMetaData( name, SqlDbType.Float ); break;<br />
case TypeCode.Empty: throw InvalidDataTypeCode( TypeCode.Empty );<br />
case TypeCode.Int16: smd = new SqlMetaData( name, SqlDbType.SmallInt ); break;<br />
case TypeCode.Int32: smd = new SqlMetaData( name, SqlDbType.Int ); break;<br />
case TypeCode.Int64: smd = new SqlMetaData( name, SqlDbType.BigInt ); break;<br />
case TypeCode.SByte: throw InvalidDataTypeCode( TypeCode.SByte );<br />
case TypeCode.Single: smd = new SqlMetaData( name, SqlDbType.Real ); break;<br />
case TypeCode.String: smd = new SqlMetaData( name, SqlDbType.NVarChar, column.MaxLength );<br />
break;<br />
case TypeCode.UInt16: throw InvalidDataTypeCode( TypeCode.UInt16 );<br />
case TypeCode.UInt32: throw InvalidDataTypeCode( TypeCode.UInt32 );<br />
case TypeCode.UInt64: throw InvalidDataTypeCode( TypeCode.UInt64 );<br />
case TypeCode.Object:<br />
if ( clrType == typeof( System.Byte[] ) || clrType == typeof( SqlBinary ) || clrType == typeof( SqlBytes ) ||<br />
clrType == typeof( System.Char[] ) || clrType == typeof( SqlString ) || clrType == typeof( SqlChars ) )<br />
smd = new SqlMetaData( name, SqlDbType.VarBinary, column.MaxLength );<br />
else if ( clrType == typeof( System.Guid ) )<br />
smd = new SqlMetaData( name, SqlDbType.UniqueIdentifier );<br />
else if ( clrType == typeof( System.Object ) )<br />
smd = new SqlMetaData( name, SqlDbType.Variant );<br />
else if ( clrType == typeof( SqlBoolean ) )<br />
smd = new SqlMetaData( name, SqlDbType.Bit );<br />
else if ( clrType == typeof( SqlByte ) )<br />
smd = new SqlMetaData( name, SqlDbType.TinyInt );<br />
else if ( clrType == typeof( SqlDateTime ) )<br />
smd = new SqlMetaData( name, SqlDbType.DateTime );<br />
else if ( clrType == typeof( SqlDouble ) )<br />
smd = new SqlMetaData( name, SqlDbType.Float );<br />
else if ( clrType == typeof( SqlGuid ) )<br />
smd = new SqlMetaData( name, SqlDbType.UniqueIdentifier );<br />
else if ( clrType == typeof( SqlInt16 ) )<br />
smd = new SqlMetaData( name, SqlDbType.SmallInt );<br />
else if ( clrType == typeof( SqlInt32 ) )<br />
smd = new SqlMetaData( name, SqlDbType.Int );<br />
else if ( clrType == typeof( SqlInt64 ) )<br />
smd = new SqlMetaData( name, SqlDbType.BigInt );<br />
else if ( clrType == typeof( SqlMoney ) )<br />
smd = new SqlMetaData( name, SqlDbType.Money );<br />
else if ( clrType == typeof( SqlDecimal ) )<br />
smd = new SqlMetaData( name, SqlDbType.Decimal, SqlDecimal.MaxPrecision, 0 );<br />
else if ( clrType == typeof( SqlSingle ) )<br />
smd = new SqlMetaData( name, SqlDbType.Real );<br />
else if ( clrType == typeof( SqlXml ) )<br />
smd = new SqlMetaData( name, SqlDbType.Xml );<br />
else<br />
{<br />
smd = new SqlMetaData( name, SqlDbType.NVarChar, column.MaxLength );<br />
coerceToString = true;<br />
}<br />
break;<br />
<br />
<br />
default: throw UnknownDataType( clrType );<br />
}<br />
<br />
return smd;<br />
}<br />
<br />
|
|
|
|
|
Hi All,
Could anybody help me out in identifying the association between the
.NET's ReleaseComObject() method and the Dispose Pattern? Are they are
similar things and serves the same purpose. Are they substitute of each
other?
This issue has become really hot for our project. Itwill be really
great if the xpert people can provide their corresponding usage for
real world applications. Differences/ Similarties between them and what
exactly they serves?
Please share your expertise and provide me some good database of
knowledge.
Thanks in advance.
Deeps
Hi All,
Could anybody help me out in identifying the association between the
.NET's ReleaseComObject() method and the Dispose Pattern? Are they are
similar things and serves the same purpose. Are they substitute of each
other?
This issue has become really hot for our project. Itwill be really
great if the xpert people can provide their corresponding usage for
real world applications. Differences/ Similarties between them and what
exactly they serves?
Please share your expertise and provide me some good database of
knowledge.
Thanks in advance.
Deeps
|
|
|
|
|
I want to create an auto response form using .net and vb.net or any other language,so that i can give instant response on my my site once a user fills a form ,Cant figure out how to do,tried but not working .
woleraymond
|
|
|
|
|
Did you try classes in the System.Web.Mail namespace?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi guys
I put some textBoxes in a form & need to let users type in one of the UTF8 languages but don't want to require them to change the language each time (not from language bar nor Alt+Shift)
Is there any specific method in dotNet or i need to override onKeyDown/press or whatever. All i can think of is mapping each EventArgs.keycode to a hexadecimal form of the corresponding unicode character 'uxxxx'?
or transpose values to get to the desired subrange in unicode?
I used Decoder.GetChars & it gives me 2 bytes for each char. How can i use these 2 bytes to transpose input char to the desired language equal?
Thanx for any hints
|
|
|
|
|
u stupid junk didn't need to spend that much time overriding OnKeyDown & do lots of mappings. U need to use InputLanguage Class 
|
|
|
|
|
Hello,
I´m new in developing for Smart Devices and I use Visual Studio 2005 Beta to develop a small c# Application that runs on a Pocket PC 2003 SE with CF2.0.
But I have a small Problem: When I copy the EXE to my Device and start my application, the application is not shown in the List of running applications?! Whenever my application runs and I open the Today Screen there is no way to get back to my application. The only way is to start the exe again! Do I have to write something in my sourcecode so that the application is shown in the List?
I hope that someone has a hint for me because I don´t know what to do
Thank you
twickl
|
|
|
|
|
Hi There!
I noticed two problems with .NET System.Windows.Forms.RichTextBox object:
1. While firing ContextMenu.Popup event from a RichTextBox object, the ContextMenu.SourceControl is always null.
2. If I want to set a menuItem Enabled or not (e.g.: Cut, Copy, Reverse, etc.) according to whether there is selected text in a RichTextBox object (I test SelectionLength > 0 or Selected{Text||Rtf}.Length > 0 during Application.Idle event and then update the command and menuItem state), I get a problem with DBCS input: the Chinese IME doesn't work anymore, the Korean IME works letter by letter instead of composing hangul characters, and the Japanese IME works randomly. As soon as I take off the test of those Selection related properties, I can do DBCS input perfectly within RichTextBox objects.
Does anybody have a clue why there are those problems and how to work around?
Thanks in advance!
Jian Yang
|
|
|
|
|
Hey Guys
I have an HTMLDocument and i want to be able to get an image on the website and display it in a listview. I can get the HTMLImage class loaded with the image element but can't seem to get the actuall image so i can display it. I have tried laoding it into a Image class but it says it won't load from a URL. Does anyone know how i would go about doing this?
Cheers
Pete
|
|
|
|
|
Can't you simply download the image, save it locally and display it in the list view? The src attribute of the img tag holds the URL of the image, so you can simply download it using HttpRequest and then give the downloaded file path to the listview.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
From the information that I have gathered it appears that XP has a limit in the resolution of timers (10-15 ms). So even though each timer can take a resoltion of 1 ms this cannot be achived in practice due to the OS limitation.
I believe that ExSetTimerResolution can be used to change this. Has anyone tried to achive this in .NET? How did you do it? Did it improve timer resolution?
Thanks,
Liam
|
|
|
|
|
You can't improve the resolution of the timers beyond 10-15ms. It's just plain impossible.
If you want sub-10ms resolution, you have to use the high performance counter built into the NT kernel, using QueryPerformanceCounter API function. There are examples of this in the CP articles, like this[^] one.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I run .net on P4 2.8 GHz and 1 GB of RAM and XP profesional machine. although i have good configuration it sucks while debugging my .net application. it takes lot of time to step into the code. due to this my production has come down. Its very difficult go step by step into the code. Could you please any one suggest me, is any patch i need to apply to fast my debugging. or do i need to do any setting. Kindly let me know.
Thanks in advance!
Umesh
|
|
|
|
|
Yeah i have the same problem. I think the problem got worse when my project became bigger and bigger. But still, it isn't nice, and it is really slowing me down aswell.
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
One thing you could try is splitting your project into parts and building the ones you're sure are working right in release mode. I've never done it in .net so I can't be more specific about how. IF you're trying to debug the processor intensive portion though you're more or less stuck unfortunately.
|
|
|
|
|
That sounds like a good idea, but i've got a lot of internal classes and stuff. If i split it up, i've got to make a lot public or re-do many things all over again. (Bad design , i know )
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Is there any chance you turned on native debugging also? I've seen that slow down debugging to a crawl.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello,
this might not be your problem at all:
I noticed slow debugging whenever a specific software firewall was running in the background on my system. Seems like component control of the firewall wanted to block some data exchange between Visual Studio and the app process. This slowed down debugging significantly and no firewall setting helped.
I solved this problem by going back to an older firewall version.
FTrader
|
|
|
|
|
How do I generate a GUID for a file and also include the GUID in the same file?
|
|
|
|
|
'The new guid
Dim g As Guid = Guid.NewGuid()
'For writing to a textfile
Dim textw As IO.StreamWriter = IO.File.CreateText("C:\SomeFile.txt")
textw.WriteLine(g.ToString)
textw.Close()
'For writing to a binary file
Dim binw As IO.FileStream = IO.File.Create("C:\SomeFile.dat")
binw.Write(g.ToByteArray(), 0, 16)
binw.Close()
Something like that.
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
I execute the following command, but want to see if it successfully created the xml file:
cmd = "bcp ""select * from dbName..tableName where StudyNo = " & SN & """ queryout c:\tResultQue.xml -c -S servername -U uname -P pwd"
Shell(cmd)
I tried the following, but it won't work as it executes before the file is created:
If File.Exists("c:\tResultQue.xml") Then
'success
Else
'failed
End If
Thank you for any help!
|
|
|
|
|
Rather than using Shell, you should create a Process object to run the command. The Process class allows you to wait for a return code that signals the execution has terminated.
|
|
|
|