|
Does anyone has a working example of XMLSQLBulkLoad from C#?
I have a dataset in C# which I am converting into XML and XSD as below
m_dsExcel.WriteXml(path+ "\\RuchiT.xml");<br />
m_dsExcel.WriteXmlSchema(path+ "\\RuchiS.xml");
Then I am making connection to SQL server as below, but nothing seems to be inserted in SQL table
SQLXMLBulkLoad3Class bulkLoad = new SQLXMLBulkLoad3Class();<br />
bulkLoad.ConnectionString = "PROVIDER=sqloledb;SERVER=servername;database=dbName;INTEGRATED SECURITY=sspi;";<br />
;<br />
<br />
bulkLoad.Transaction = false;<br />
bulkLoad.BulkLoad = true;<br />
bulkLoad.SchemaGen = true;<br />
bulkLoad.KeepIdentity = true;<br />
<br />
bulkLoad.Execute(RuchiS.xml, RuchiT.xml);
Any clues???? Appreciate you help.
Thanks
Ruchi
|
|
|
|
|
Don't know quite how to word this question, thus I have not search for it, but is there a way to eliminate all the HTML from the code of an ASPX page? Meaning, if I did Response.Write("blah")
and did View Code, all I would see would be blah?
The reason I ask is that I need to call an aspx page from Flash and get the data returned, but it must be in the form blah=what&count=1 etc... Unless there is a better way. Any suggestions?
|
|
|
|
|
just call in the Page_Load event handler Response.Clear(), then write all you want.
|
|
|
|
|
Hi all,
I am new to this forum. We are developing a project to upload media files (wma and wmv). For that we need to validate the files. The thing I am not getting is: Is there any ways to check (retrieve) the Bit Rates of a specified file. Help is very much appreciated.
Regards,
Jagannathan Sridharan
|
|
|
|
|
I believe that in all wm* files there is at least an 'average bitrate' tag inside the file: try to open one of them with a hex editor and you'll locate it. the problem is that the tag is not written in plain text, but in a unknown (at least to me!!!) binary format, such as 'avgbitrateSOMEINVISIBLECHARS'.
|
|
|
|
|
Thanks darisole,
My scenario is this: The user can select a media file (from remote machine). I should get that file, but before uploading it to the server I need to check the Bit Rates(average bit rate). Programmatically, I should do everything. For that, Do I need to use some SDKs? Like, Windows media Player SDK etc.,
Thanks very much once again,
Jagannathan Sridharan.
|
|
|
|
|
I'm afraid I don't know if in the Windows Media SDK there are some APIs to do read the bitrate from wm files.
this is what I found with an hex editor in a VBR wma file:
................
V.B.R...........
................
you can see that it is almost impossbile to understand the formats.
I believe in the WM SDK there is a win32 api that does the work, but if it is so, you have to wrap it in a .NET class library. it may be very difficult, especially if there isn't much documentation about it.
|
|
|
|
|
I have to scratch my head with WM SDK I guess. Neways thanks darisole.
|
|
|
|
|
Hello,
I'm Ashwini currently pursuing my B.Tech. We have an RDBMS project this semester. We(a group of 4 members) have decided to use C#.Net as the front-end. Can u please give us some help regarding this as soon as possible.
Ashwini
|
|
|
|
|
Help with what? You need to ask a more specific question.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi for all
I don't understand what's going on. I have a client-server app with 2 threads. They do the same work, that is: the current thread calls a thread to execute a draw method on my form. In first time the method works good(both of them). But in the second nothing is drawed. I put my code now:
//the threaded method
public void Running()
{
try
{
while(true)
{
Connexion = ServerListener.AcceptSocket();
if(Connexion.Connected)
{
DataStream = new NetworkStream(Connexion);
Reader = new BinaryReader(DataStream);
Writer = new BinaryWriter(DataStream);
m_bConnect = true;
do
{
sData = Reader.ReadString();
using(Draw Desenho = new Draw())
{
//the called method
Desenho.GetCoordinates(sData+Form1.stCoordinates, G, true);
}
}while(DataStream != null && sData != "Close connection");
}
}
Reader.Close();
Writer.Close();
DataStream.Close();
Connexion.Close();
Application.Exit();
}
Notice that I pass a Graphics parameter, that is a private Graphics variable of my class. When I close my applications the following error appears:
"An undhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurried in System.Drawing.dll
Additional information: A generic error ocurried in GDI+."
What is going on?
Thanks a lot!
C#er
|
|
|
|
|
Dont close the DataStream. It sucks I know. I had a similar situation,
Check this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDrawingBitmapClassctorTopic6.asp
You must keep the stream open for the lifetime of the Bitmap object.
The situation is similar.
Live Life King Size
Alomgir Miah
|
|
|
|
|
Man, I commented out the "DataStream.Close()" and the problem persists.
I've no idea what this problem occurs.
Can you help me again Alomgir Miah? Thanks a lot!
|
|
|
|
|
I know one thing for sure, this problem is caused by streams. Please comment out all the close statements and test by uncommenting them one by one. ( I know its a layman solution). Still give it a shot.
One more thing - are you using streams elsewhere.
If you see the debug trace and call stack, you will realize that the exception occurs in the Paint event handler. Follow the details of the exception you get, you will get that answer. In the onpaint method, the GDI is accessing some null values (which you will have to find).
If nothing works, worst case scenario, the quickfix is override the OnPaint event handler and catch the exception but dont handle it.
protected override void OnPaint(PaintEventArgs e)
{
try
{
base.OnPaint (e);
}
catch
{
//Do Nothing
}
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
Man, I think that you'll scold me a lot. The problem was I'm not breaking a "while" statement. Sorry, sorry, sorry. Thanks for help one more time and for the tips.
|
|
|
|
|
Never mind.
Live Life King Size
Alomgir Miah
|
|
|
|
|
I read a bitmap from file with the following code:
Bitmap tempBitmap = new Bitmap(bitmapFileName);
Later I want to save an updated version of the bitmap with this code:
if (System.IO.File.Exists(bitmapFileName)
System.IO.File.Delete(bitmapFileName);
tempBitmap.Save(bitmapFileName);
Unfortunately, when it gets to the delete, I get the following error:
"System.IO.IOException: The process cannot access the file "filename.bmp" because it is being used by another process."
The creation of the bitmap from file is holding on to the connection. I tried cloning and copying to the clipboard, but the only way I have been able to get this to work is by copying all my bitmaps to temp files and opening from the temp file. Then the file I delete and save to is a different file. I am hoping there is a better way.
|
|
|
|
|
The Bitmap object holds the file open for the lifetime of the object. The trick is to read the file yourself, create the bitmap from that stream, then close the stream.
FileStream fs = new FileStream(@"C:\bitmap.bmp");
Bitmap b = new Bitmap(fs);
fs.Close();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
From MSDN,
You must keep the stream open for the lifetime of the Bitmap object.
Live Life King Size
Alomgir Miah
|
|
|
|
|
I tried using the Filestream and closing it after creating the bitmap. It is working. Why must the stream remain open?
|
|
|
|
|
If its working thats fine. But in some situations you might get Generic GDI+ error.
Check this
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDrawingBitmapClassctorTopic6.asp
So you should implement IDisposable interface and close the stream when Dispose Method is called.
I have written a BitmapHelper, hope this helps,
using System;
using System.IO;
using System.Drawing;
namespace Test.Controls
{
///
/// Summary description for BitmapHelper.
///
public class BitmapHelper: IDisposable
{
private Bitmap _bm;
private Icon _ic;
private MemoryStream _ms;
// Track whether Dispose has been called.
private bool disposed = false;
public BitmapHelper()
{
}
public void LoadBitmap(Stream sm)
{
Clear();
int len = (int) sm.Length;
byte[] buf = new byte[len];
sm.Read(buf,0,len);
_ms = new MemoryStream(buf);
_bm = (Bitmap) Image.FromStream(_ms);
}
public void LoadIcon(Stream sm)
{
Clear();
int len = (int) sm.Length;
byte[] buf = new byte[len];
sm.Read(buf,0,len);
_ms = new MemoryStream(buf);
_ic = new Icon(_ms);
}
public void LoadBitmap(string fileName)
{
FileStream fs = new FileStream(fileName,FileMode.Open,FileAccess.Read);
LoadBitmap(fs);
fs.Close();
}
public void LoadIcon(string fileName)
{
FileStream fs = new FileStream(fileName,FileMode.Open,FileAccess.Read);
LoadIcon(fs);
fs.Close();
}
public void LoadBitmap(object dbField)
{
Clear();
if (dbField != DBNull.Value)
{
byte[] buf = (byte[])dbField;
_ms = new MemoryStream(buf);
_bm = (Bitmap) Image.FromStream(_ms);
}
}
public void LoadIcon(object dbField)
{
Clear();
if (dbField != DBNull.Value)
{
byte[] buf = (byte[])dbField;
_ms = new MemoryStream(buf);
_ic = new Icon(_ms);
}
}
public void Clear()
{
if (_bm != null)
{
_bm.Dispose();
_bm = null;
}
if (_ic != null)
{
_ic.Dispose();
_ic = null;
}
if (_ms != null)
{
_ms.Close();
_ms = null;
}
}
// Implement IDisposable.
// Do not make this method virtual.
// A derived class should not be able to override this method.
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
// Dispose(bool disposing) executes in two distinct scenarios.
// If disposing equals true, the method has been called directly
// or indirectly by a user's code. Managed and unmanaged resources
// can be disposed.
// If disposing equals false, the method has been called by the
// runtime from inside the finalizer and you should not reference
// other objects. Only unmanaged resources can be disposed.
private void Dispose(bool disposing)
{
// Check to see if Dispose has already been called.
if(!this.disposed)
{
// If disposing equals true, dispose all managed
// and unmanaged resources.
if(disposing)
{
// Dispose managed resources.
this.Clear();
}
// Call the appropriate methods to clean up
// unmanaged resources here.
// If disposing is false,
// only the following code is executed.
}
disposed = true;
}
public Bitmap Bitmap
{
get
{
return _bm;
}
}
public Icon Icon
{
get
{
return _ic;
}
}
}
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
Never have I had a problem with a Generic GDI error while using a Bitmap object. And I've created Bitmap objects from just about every imaginable source, be it a resource stream, external file, serialized network stream, XML data, SQL database, ... Come to think of it, I've never had a GDI+ error that wasn't caused by me doing something stupid, like trying to draw to the same object from two different threads at the same time.
If you have to keep the stream open, why does MSDN have an article that shows you how to get around this -> PRB: Image File Is Locked When You Set the PictureBox Image Property to a File[^]
The Bitmap class inherits from Image, so I fail to why you would have to keep the stream open for a Bitmap object and not for an Image object.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Closing the stream is working for me.
Thanks
|
|
|
|
|
Straight from MSDN
Remarks
You must keep the stream open for the lifetime of the Bitmap object.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDrawingBitmapClassctorTopic6.asp
This happens sometimes when the OnPaint tries to access the BitMap and
gets a null.
Live Life King Size
Alomgir Miah
|
|
|
|
|
So it is...
But, like I said, never had a problem with it.
I fail to see why any Bitmap object (properly defined) would ever come back as null in the middle of OnPaint. I've never had it happen in any painting of any of my forms or controls.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|