|
Hi
iam in windows application in c#
my database is "Firebird Database";
iam saving an picture into database.but iam unable to retrive same picture from database
mycode is :
This code is in DataAccess layer.
string query = "select photo from cust1 where id=" + id;
FbDataAdapter adb = new FbDataAdapter(query, cnn);
DataSet ds = new DataSet();
adb.Fill(ds, "cust1");
if (ds.Tables[0].Rows.Count > 0)
{
DataRow dr;
dr = ds.Tables[0].Rows[0];
if (!dr["photo"].Equals(DBNull.Value))
{
byte[] content = (byte[])dr["photo"];
MemoryStream stream = new MemoryStream(content);
photo = stream;
}
}
Bitmap img = new Bitmap(objcls.photo);---------------"ERROR"
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Image = img;
it is giving error "parameter is not valid"
please inform where the exact problem is
murali krishna
|
|
|
|
|
avvaru.murali wrote: please inform where the exact problem is
We can't tell you the "exact" anything unless you explain your problem better. You need to give us more information:
What is photo?
What is the error?
|
|
|
|
|
I have some question regarding DB, if u fellows answer them:
a) What is diffrence between creating connection thru VS designer wizard And doing same by coding?
Which is better.
b) what these lines means
((System.ComponentMode1.IsupportIntialize)(this.dsComp)).BeginInit();
((System.ComponentMode1.IsupportIntialize)(this.dsComp)).EndInit(); auto generated by VS designer?
c)
this.textBox.DataBinding.Add(new System.Window.Forms("Text", dt, "State"));
this.textBox.DataBinding.Add("Text", dt, "State"));
textBox.DataBinding.Add("Text", dt, "State")); what is diffrence between these lines, I tried all for same control, they work fine with no error, But which one to use?
Thanks & regards.
|
|
|
|
|
humdumof wrote: a) What is diffrence between creating connection thru VS designer wizard And doing same by coding?
Which is better.
The wizard can only ever put the code in your presentation layer. This is not the place for database code.
Doing it by hand means that you can create a proper DAL (Data Abstraction Layer)
humdumof wrote: System.ComponentMode1.IsupportIntialize
That does not exist. Please copy and paste the code properly. The actual interface is called System.ComponentModel.ISupportInitialize
Have you tried reading the documentation[^]?
I'm guessing that the object is a DataSet. If not then please tell us what it is, it wastes time trying to guess this sort of thing. If it is a dataset the BeginInit[^] and EndInit[^] methods are documented.
humdumof wrote: //dt for datatable, state is field in dt
this.textBox.DataBinding.Add(new System.Window.Forms("Text", dt, "State"));// line 1
this.textBox.DataBinding.Add("Text", dt, "State"));// line 2
textBox.DataBinding.Add("Text", dt, "State"));// line 3
what is diffrence between these lines, I tried all for same control, they work fine with no error, But which one to use?
The difference between line 2 and 3 is so basic I'd suggest you really need to read a beginners book on C# if you can't see what is happening.
this is a keyword that refers to the current instantiated object the code is operating within. For the most part it is optional. If you have a local variable with the same name as a class member then you need to use this . If not, then its use is completely optional you can use it or not. It makes no difference.
The difference between lines 1 and 2 can be found in the documentation. You can access the documentation by pressing F1 in Visual Studio. Or you can go to http://msdn.microsoft.com[^] and there is even a Vista Gadget where you can type in search terms and it will take you directly to the documenation.
|
|
|
|
|
Hello everyone!
I'm wondering if you could give me some tips on managing keyboard shortcuts in a winform application. I want to be able to create a dialog where the user can change the keyboard shortcuts to different commands. Right now I just add them to the ShortcutKeys property of a menu item and thats not very manageable.
Thanks in advance!
-Martin
|
|
|
|
|
Hi,
Dear you have to store the text property of that object say in (setting.config) some ware and then each time you load your application you can read that setting.config file to put the that text for that object in the winform.
Regards
|
|
|
|
|
Not exactly sure how you mean. I think I understand that you want me to connect the ShortcutKeys property to a user setting in Settings.settings? If I create a new MenuItem class which has a command class connected to it this could work but what about the keyboard shortcuts that I want connected to a command which is not in the menu?
What I want it something like what Visual Studio has. All the different commands show up in a list and you can connect keyboard shortcuts to them. I also want plug-ins to be able to add their commands to the list.
Let's say I have all these command classes; NewFileCommand, OpenFileCommand, ExitApplicationCommand, etc. I also have a plug-in which has too commands; ShowGraphPlugin, ShowListPlugin. Now I need to get these commands into the keyboard shortcut configuration dialog and be able to connect a command to a keyboard shortcut. Not sure how to do that...
-Martin
|
|
|
|
|
I was thinking, if I create a new menu item class that is connected to a command class/object. Wouldn't it be better if I concentrate on connecting a keyboard shortcut to a command instead? Then when the menu item gets the command it can somehow retrieve the connected keyboard shortcut (if any) and show it as it's own keyboard shortcut?
Then I guess all the keyboard shortcuts in the application would have to go through some manager class and I would have to have some list connecting commands to shortcut keys...
Is this good or bad?
-Martin
|
|
|
|
|
hey everyone, i'm writing a 3d game using truevision 6.3 as the game engine. it's a racing game but i still can't figure out how to turn with the directional key rather than a mouse. the whole concept of the game is to use first person view while racing instead of the camera following the mesh/actor.
please if anyone can help me out lemme know. i've got just 2 months to present this as my final year project.
thanks
|
|
|
|
|
anarchi23,
Might be a better idea to ask on the "truevision" forum.
Regards,
Gareth.
|
|
|
|
|
hi all
How can I send an email with C#?
|
|
|
|
|
using System.Net.Mail
Crate a object of MailMessage Class
MailMessage Mail = new MailMessage();
Now set , Mail.To, Mail.From, Mail.Subject, Mail.Body Property.
Create object of Smtp Class
SmtpClient ss = new SmtpClient("Server");
Now Send
ss.Send(Mail)
This is basic idea. You will get lots of sample by googling !!!!!
Good luck
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
modified on Saturday, February 23, 2008 6:08 AM
|
|
|
|
|
Hey guys, I'm using stored procedure to insert data to my database, I works perfectly. after clickin the button it inserts the information. but when I again want to enter new information and press the button I get this error >> Procedure or function ExpenseEntery has too many arguments specified.
<br />
InsertCmd.Connection = MyCon;<br />
InsertCmd.CommandType = CommandType.StoredProcedure;<br />
InsertCmd.CommandText = "ExpenseEntery";<br />
<br />
InsertCmd.Parameters.Add("@ID", SqlDbType.Int).Value = GetID;<br />
InsertCmd.Parameters.Add("@ClientID", SqlDbType.Int).Value = UserID;<br />
InsertCmd.Parameters.Add("@ExpenseID", SqlDbType.TinyInt).Value = SelectedExpense;<br />
InsertCmd.Parameters.Add("@DateOfPurchase", SqlDbType.VarChar, 8).Value = SelectedDate;<br />
InsertCmd.Parameters.Add("@Cost", SqlDbType.Money).Value = Convert.ToInt64(Cost_tb.Text);<br />
InsertCmd.Parameters.Add("@Number", SqlDbType.Int).Value = Convert.ToInt32(Number_tb.Text);<br />
InsertCmd.Parameters.Add("@TotalCost", SqlDbType.Money).Value = Total;<br />
InsertCmd.Parameters.Add("@Comment", SqlDbType.NVarChar, 300).Value = Comment_tb.Text;<br />
InsertCmd.Parameters.Add("@DeleteFlag", SqlDbType.Bit).Value = "false";<br />
<br />
MyCon.Open();<br />
InsertCmd.ExecuteNonQuery();<br />
MyCon.Close();
|
|
|
|
|
seems that you use InsertCmd again without clearing its parameters.
Clear the command parameters or create a new instance.
|
|
|
|
|
thanx buddy ! it solved the problem !!!
Mr.K
|
|
|
|
|
Or only add them the first time.
|
|
|
|
|
Yes.thats right
Because every time that you execute your methode, InsertCmd object define some parameter with same name.
Define InsertCmd in local manner.
|
|
|
|
|
Hello Everybody,
I need help for generating Random Numbers......
and need to add current system date with that generated number....
Please help
Thanks
modified on Saturday, February 23, 2008 4:45 AM
|
|
|
|
|
base64 is an encoding not a number system, what do you need to do exactly? generate a number then encode it ?
|
|
|
|
|
Hi,
its a mistake in writting question.
i want to generate random numbers that unique with a combination of current date...
means if my random number is 757454584 then its will never generate again so i want some extra digits at the end for unique number that i think the current date 757454584 + 230208
so it will give me the perfect random number...
But i am unable to achive this..
can u help me...
|
|
|
|
|
Dikshant,
Random random = new Random();
string randomString = (DateTime.Now.ToString() + "_" + random.Next().ToString());
random.Dispose();
Above gives you "23/02/2008 11:08:23_3243243242"
|
|
|
|
|
Hi,
what exactly are you trying to accomplish? Do you need a specific distribution, or a constant length, for example?
If you just need some keys that do not collide, i.e. keys which are (almost) unique, you might want to take a look at UUIDs or GUIDs. They are time-based, but in a more subtle manner. Their length is constant. However, they are usually written in hexadecimal strings, e.g.: {2AED1BB2-7314-43e9-9DE7-8AAB3BBC20C1}.
Or do you just need something like
Random a = new Random();<br />
string x = String.Format("{0}{1}", a.Next(), DateTime.UtcNow.Ticks);
?
yielding, for example, this:
"2143552667633393651580403445"
Note that this has a variable length, because
a.Next() returns some number which can be shorter or longer.
Also note that a, if initialized without a seed will use the system time as seed, thus creating completely different numbers on each run (these alone, however, have a rather large chance of colliding).
In general, there are no keys which can *never* collide (unless they have infinite legth...), but you can make it extremely unlikely to happen.
Hope that helps,
Chris
"Obstacles are those frightening things you see when you take your Eyes off your aim"
- Henry Ford
Articles
Blog
|
|
|
|
|
Please avoid removing a question that someone already has replied to. It's a bit confusing to read replies to a question that has changed completely. You can strike out text when you edit the question.
You can use the Ticks property to get a DateTime value as a number.
You should use DateTime.UtcNow rather than DateTime.Now to get the time. The local time is affected by daylight savings time, so it's not unique, i.e. once a year it overlaps for an hour.
string id = myRandomNumber + "_" + DateTime.UtcNow.Ticks.ToString();
But if you want a unique random number, why are you not using a GUID?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thank you all for solution....
And Sorry that i have to edit it.....
Again thanks
Dikshant
|
|
|
|
|
You can use GUIDs. or use Cryptography classes (as RNGCryptoServiceProvider ) to generate the random value.
The advantage of using RNGCryptoServiceProvider is that you can select the length of the generated value.
Here is an example (I choosed the length = 50):
using System.Security.Cryptography;
.
.
.
byte[] data = new byte[50];
RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
for (int i = 0; i < 50; i++)
{
rand.GetBytes(data);
string s = Convert.ToBase64String(data);
Console.WriteLine(s);
}
|
|
|
|