|
I have never pulled an image out of a database. I don't know what a winforms app is? can I use that in C# webform? It's all new to me.
|
|
|
|
|
OK
A winforms app is an app in .NET that makes a windows application instead of a web one. If that's hard for you right now, then perhaps it's an unnecessary diversion. You could perhaps try something like this:
System.IO.MemoryStream ms = new System.IO.MemoryStream(picture.Data);
System.Drawing.Bitmap bmp = System.Drawing.Bitmap.FromStream(ms) as Bitmap;
bmp.Save(@"c:\test.jpg");
which, assuming your data is meant to be a jpg, should save it to disc. If it does, then your class is reading the image fine. picture.Data is meant to be whatever your class instance is, and it's property for the byte[].
At this point I still have no idea what your trouble is. You started by saying you get an error, and you've still not told me what it is.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok my reply was dumb, haven't used windows applications at all. lol did I mention I was blond? I think I have to do the Response.BinaryWrite thing. the error I get is
System.Data.SqlClient.SqlException: A severe error occurred on the current command. The results, if any, should be discarded.
|
|
|
|
|
OK - at that level it looks like your code is not getting to the point of pulling the data from the database. Do you know what line is causing the error ? Do you know how to set breakpoints and step through your code ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
this is my code in pageload:
int ID = 1;
picDB myPic = new picDB();
picDB.PictureData myPictureData = myPic.GetPrictureDetails(ID);
Response.ContentType = myPictureData.contenttype;
Response.BinaryWrite (myPictureData.data);
I get this one error :
General network error. Check your network documentation. that one comes and goes with this same problem. read up on it and it's just a strange thing and stops at my
myCommand.ExecuteNonQuery();
the other error happens at the same point:
A severe error occurred on the current command. The results, if any, should be discarded.
|
|
|
|
|
Judy101101 wrote: GetPrictureDetails
You know there's a typo here, right ?
Judy101101 wrote: myCommand.ExecuteNonQuery();
It looks to me like your problem is connecting to the database.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
here is my stored procedure, I don't think there is anything wrong with it, but never worked with images before
CREATE PROCEDURE GetPictures
@ID int,
@name varchar OUTPUT,
@data image OUTPUT,
@contenttype varchar OUTPUT
AS
SELECT
img_name = @name ,
img_data = @data,
img_contenttype = @contenttype
FROM Image
WHERE
img_pk = @ID
GO
|
|
|
|
|
Here[^] is an article on saving/loading images in SQL Server and C#.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi...
Close the database connection after you fill myPictureData...
<br />
myConnection.Open();<br />
myCommand.ExecuteNonQuery();<br />
<br />
PictureData myPictureData = new PictureData();<br />
<br />
myPictureData.ID = (int)parameterID.Value;<br />
myPictureData.name = (string)parametername.Value;<br />
myPictureData.data= (byte[])parameterdata.Value;<br />
myPictureData.contenttype = (string) parametercontenttype.Value;<br />
<br />
myConnection.Close();<br />
<br />
return myPictureData;
Free your mind...
|
|
|
|
|
Exactly what error are you getting? Nothing in your code is jumping out at me. The only thing I see that looks like a problem is that your accessing the parameter values after you have closed the connection.
|
|
|
|
|
Hello,
I have an issue as I am trying to use remoting in my VS 2005 project, with Ipc channels.
I have the assembly myproject.dll, containing all the necessary implementation for server and client processes to use it for remoting:
IMyObject
CMyObject : IMyObject
CMyObjectRemoteClient : IMyObject
CMyObjectRemoteServer : MarshalByRefObject, IMyObject
I have a first process, the server, instantiating CMyObjectRemoteServer, registring the channel, etc. All goes well for that part:
// Create Ipc Channel
m_oIpcServerChannel = new IpcServerChannel("myproject");
// Register to the IPC channel
ChannelServices.RegisterChannel(m_oIpcServerChannel, false);
//register remote object
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(CMyObjectRemoteServer),
"CMyObject",
WellKnownObjectMode.Singleton);
I have the second process, the client, doing the following:
// Create Ipc Channel
m_oIpcClientChannel = new IpcClientChannel("myproject", null);
// Register to the IPC channel
ChannelServices.RegisterChannel(m_oIpcClientChannel, false);
// Get the remote object
remoteObject = (IMyObject) Activator.GetObject(
typeof(CMyObjectRemoteServer),
"ipc://myproject/CMyObject");
So far, all is good. No exception. But then I try to call a function of my object:
remoteObject.Open();
And I get the following exception:
1724 RemoteTester. WARNING 18:49:57:246 00e9c MyNamespace::CMyObjectRemoteClient.Open() Error calling remote object function: Could not load file or assembly 'myproject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
The first process is nothing but an exe using myproject.dll to get a CMyObjectRemoteServer object. It works good.
The second process is also a simple exe using myproject.dll to get a CMyObjectRemoteClient object.
The 2 exe of the client and server, and myproject.dll are all in the same folder. I also checked:
typeof(CMyObjectRemoteServer).Assembly.CodeBase
typeof(CMyObjectRemoteClient).Assembly.CodeBase
to find out they really point to the right place, and all looks fine.
It works good until it fails to locate the assembly 'myproject', where it actually got CMyObjectRemoteClient, which also contains CMyObjectRemoteServer object from (if this is what it looking for). Duh! What is going wrong, and why does it fail loading the assembly?
Thanks for your help!
-Sly
There are 3 types of people in this world, people who understand binary, and those who don't.
-- modified at 19:06 Thursday 24th November, 2005
|
|
|
|
|
Hi
I'm in the process of setting up the security module for a new c# windows application.
Basically I import employee data (last name, first name) from an existing HR system. The employee needs to be assigned a UserName to allow them to login to the new application. UserNames are assigned to various groups which enable or disable different buttons etc.
I know this seems pretty standard, but I require this in c# and I can't find an example to get me started.
I think ideally it should work like the windows local user/group security or SQL server login/user/role security.
If I used SQL server as the backend database would it be better to integrate my c# application with sql server security? Again, I can't find any code or project samples.
Many thanks
J
|
|
|
|
|
Hi,
I want to draw a line on a WinForm.
Assume that the line drawn will have the following coordinates:
(0, 0, 100, numericUpDown value)
I want the numericUpDown value to be tied to a Button.
When the button is clicked the line is drawn on the form.
Thanks in advance.....
|
|
|
|
|
Drawing has to happen in your paint handler, so your paint handler should know if it has to draw the line, and if so, get it's values from member variables. Your button handler should update those values and call Invalidate();
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can anyone help me? I`ve just started my adventure with .NET.
I want use regular expression in my text box to validate text. For example reg. expression like this : "[0-9][0-9]-[0-9][0-9][0-9]" accepts only for example "43-456" text. What if I enter "54-8f5" ? .NET Regular Expressions tells me that this text is not correct. But it doesn`t tell me which character is invalid.
My problem is that I want .NET Regular Expressions show me which character (which character index in this incorrect string) is invalid.
Can anyone help with this?
conrados
|
|
|
|
|
|
Hello all,
i am using Datagrid to dispay row directly from my database but i need to click on one row to open details for this row from another table in the database where i can hang the value for the row with specifc row like in the combobox ValueMember
Thanks for help
Hoho
|
|
|
|
|
DataRowView currentRowInTheGrid = (DataRowView)this.dataGrid1.BindingManager[this.dataGrid1.DataSource, this.dataGrid1.DataMember].Current;
I hope you understand...because is a rough world out there...
|
|
|
|
|
Thanks so much about your help
but i need to know the ID of this current record to select the related details with this ID.
thank
hoho
|
|
|
|
|
Having the dataRowView you can obtain the coresponding dataRow :
DataRowView currentRowInTheGrid = (DataRowView)this.dataGrid1.BindingManager[this.dataGrid1.DataSource, this.dataGrid1.DataMember].Current;
DataRow currentRow = currentRowInTheGrid.Row;
object myId = currentRow["myIdColumnName"];
I hope you understand...because is a rough world out there...
|
|
|
|
|
Alright, I'm writing a bunch of integers to the screen of different lengths, followed by other numbers.
Some are 3 digits long, some are five digits long, and the maximum is about 6 digits long.
If the number is less than 6 digits long, I want it to write extra spaces after the number, to make it 6 total characters, before displaying more data.
Etc.
How do I do this?
Thanks, As Always.
|
|
|
|
|
You should take a look at the Composite Formatting article on MSDN. It shows you the ins and outs of the process.
For your immediate satisfaction, though, try this:
String.Format( "{0,-6} {1,-6} {2,-6}", 7, 3.14, 0.5 );
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
-- modified at 19:58 Thursday 24th November, 2005
|
|
|
|
|
I have 1 quick question
Example:
if(!Page.IsPostBack)
{
}
OR
if(Page.IsPostBack == True)
{
}
does the compiler treat the above statments the same, or is one more efficient then the other, cpu cycles etc....
|
|
|
|
|
They are different, not because of the way that you've written them, but because the logic is different.
The first example, in pseudo code, says
IF PAGE IS NOT POSTBACK
While the second example, in pseudo code, says
IF PAGE IS POSTBACK
I wrote a wee program that tested both in release mode to see what the generated IL was:
if (isBlah)
{
Console.Write("It is Blah");
} became:
.maxstack 1
L_0000: ldarg.0
L_0001: brfalse.s L_000d
L_0003: ldstr "It is Blah"
L_0008: call void [mscorlib]System.Console::Write(string)
L_000d: ret
And
if (isBlah == true)
{
Console.Write("It is Blah");
} became:
.maxstack 1
L_0000: ldarg.0
L_0001: brfalse.s L_000d
L_0003: ldstr "It is Blah"
L_0008: call void [mscorlib]System.Console::Write(string)
L_000d: ret
So, you can see they are exactly the same thing. Which ever that you use is entirely up to you. What ever you feel more comfortable with the compiler will still turn it in to the same code.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I did another quick test to show
if(!isBlah) Vs. if (isBlah == false)
The result was code exactly the same length as before. So, even by adding in the ! (not) operator there is no performance difference.
So, it all comes down to what ever is most readable for you.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
-- modified at 14:29 Thursday 24th November, 2005
|
|
|
|