|
Yes, now i found that there is such thing . THANKS !!!!!!!!!!!!!!!!!!!!!!!!!
One nation - underground
|
|
|
|
|
I have a question regarding the BinaryReader class and C#. I have been assigned a task at work to read raw data from an application file and search the file for a specific hex data occurance...
The problem is when I run the test application I wrote to open and read data from the file the app only prints out one line to the command prompt and its garbage.
My question is what is the basic layout to open a file and read raw data?
forgive me I'm new to C# and I'm still learning. When reading raw data is there specific formatting I have to take into account?
BinaryReader br = new BinaryReader(File.OpenRead(filename));
Byte fileB = br.ReadByte();
System.Console.Writeline(fileB);
|
|
|
|
|
Does not generally write to the console very well, it is binary. If you really want to read it you would base64 encode it to view it.
The actually format of the file should be defined by the class that wrote the file.
Also a byte goes 0 to 255, printable characters are above 32? I believe.
File Not Found
|
|
|
|
|
Hi
I have an image list with 52 items in it. how would I instiate it and display the images in a drawn control picture box?
Thanks
KN
michael
|
|
|
|
|
Can't you pull the image out by index ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ImageList has a property that allows access to the array of images in it. You can access them by their index.
Image img = imageList1.Images[0];
pictureBox1.Image = img;
|
|
|
|
|
Question 1form1)
How to compare my default password that i save in notepad.
How to compare with the password that user input in text box.How to call the password that have key in the notepad.
Question 2:
In another form I make to textbox one for user input old password and another textbox for user input new password.The new old password will be replace by the new password in the notepad.After this it will compare with the new password in the form1
Tq.Help Needed
|
|
|
|
|
notepad is a program. I assume you don't have notepad open ? File.ReadAllText will read the text in a text file, so you can compare it. Why would you store your password in a textfile ?
Can you explain what you mean ? Because, notepad has nothing to do with your password, even if it can display it. And, if it can, it's so insecure that there's no point in it existing. What sort of app is it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi sir...
I have create login form that have one textbox and 1 ok button.How to store a password in database and retrieve it to compare with user inputed password in the text box.
Another question:
I have form2 that for user change password.In this form have two text box. One for user input the old password and another for user key in new password.After it compare that the old password in text box one .It will replace in database with new password.
After that in form one it will compare the text box input with the new password in database.
I think sir familiar with this all.
Tq sir.
|
|
|
|
|
Hash the password when inserting it into the database and compare the hash values, not plain text.
Can you use the built in ASP.NET 2.0 login controls? It would save a lot of work on your part.
only two letters away from being an asset
|
|
|
|
|
Sir this is for window form. Sir how to save password in database.How to compare when click ok button with the input in textbox.tq
|
|
|
|
|
krajah1984 wrote: Sir this is for window form.
No, ASP.NET is, by definition, NOT windows forms, but web forms.
krajah1984 wrote: Sir how to save password in database
Do you not know how to use a database ? For that sort of beginner info, you're better off buying a book.
krajah1984 wrote: How to compare when click ok button with the input in textbox
The best way is a stored proc that takes the username/password and returns a success code. That way, the actual password never leaves the data layer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
only two letters away from being an asset
|
|
|
|
|
Hello,
You can use your Windows Form to get connected to your Database. There are number of choices that you have to make regarding the database server and then you can get connected to the database and have the luxury of sending and receiving data between your Windows Application and the database, such as storing Passwords, checking the login information and etc.
I personaly use MySQL and it works just fine. Could you tell us what data base you are using so I can direct you to some Beginer's tutorial and get you started with simple commands to get you started?
I hope I could be a help.
Khoramdin
-- modified at 12:00 Tuesday 27th March, 2007
|
|
|
|
|
Tq sir,
I'm using mysql.How to connect to mysql using visual C#.How to compare the password. Can you help me sir.
Before this I have create a password form that I set default password in coding of button click.
I want to upgrade it so I can compare password and change password from the database.Tq sir
|
|
|
|
|
Hello mate,
Windows Applications were never meant to be connected to anythingelse than MS product. But you are in LUCK as there are ways to make your Windows Application work flawlessly with other technologies such as MySQL.
Step 1:
In order for your Windows Application written in C# to get connected to MySQL you need to have the right driver. You can get this from the good old MySQL website. Here is the link to save you the time and the headache looking for it, mate.
http://dev.mysql.com/downloads/connector/odbc/3.51.html[^]
Download and install the right package and then you are ready for Rock & Roll.
Step 2:
Add the following into your C# Windows Application:
private System.Data.Odbc.OdbcConnection OdbcCon;
private System.Data.Odbc.OdbcCommand OdbcCom;
private System.Data.Odbc.OdbcDataReader OdbcDR;
private System.Data.Odbc.OdbcDataAdapter OdbcAd;
private string ConStr;
Step 3:
Now you are ready to talk to your Database, mate. Just talk to your database using MySQL commands. What can be done is simply limited only by your imagination.
Here is a few examples to set you in the right direction.
Example 1: Getting Connected to MySQL database:
private void btnConnect_Click(object sender, EventArgs e)<br />
{<br />
ConStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" + txtIP.Text + ";PORT=" + txtPort.Text + ";DATABASE=" + txtDatabase.Text + ";UID=" + txtUsername.Text + ";PWD=" + txtPassword.Text + ";OPTION=3";<br />
OdbcCon = new System.Data.Odbc.OdbcConnection(ConStr);<br />
btnListTables.Enabled = true;<br />
<br />
try<br />
{<br />
txtLog.AppendText("Openning connection...\r\n");<br />
if (OdbcCon.State == ConnectionState.Closed)<br />
{<br />
OdbcCon.Open();<br />
}<br />
txtLog.AppendText("Connection opened\r\n");<br />
}<br />
catch (System.Data.Odbc.OdbcException Ex)<br />
{<br />
txtLog.AppendText(Ex.Message + "\r\n");<br />
MessageBox.Show("Could not access the database.\r\nPlease make sure you completed the fields with the correct information and try again.\r\n\r\nMore details:\r\n" + Ex.Message, "Database connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
}<br />
Example 2: Showing all the tables:
private void btnListTables_Click(object sender, EventArgs e)<br />
{<br />
if (OdbcCon.State == ConnectionState.Open)<br />
{<br />
OdbcCom = new System.Data.Odbc.OdbcCommand("SHOW TABLES", OdbcCon);<br />
OdbcDR = OdbcCom.ExecuteReader();<br />
txtLog.AppendText("Tables inside " + txtDatabase.Text + ":\r\n");<br />
while (OdbcDR.Read())<br />
{<br />
txtLog.AppendText(">> " + OdbcDR[0] + "\r\n");<br />
}<br />
}<br />
}
For some reason you are seeing the words PORT as ";PORT" and PWD as ";PWD" in the above code. Just replace the smily faces with the correct word and you should be alright. You need to place ";" before the word PORT and PWD. I guess ";" + "P" gives the smily face.
By the, my humble apology for the messy codes.
I hope this gets you started.
Khoramdin
-- modified at 12:49 Tuesday 27th March, 2007
|
|
|
|
|
Hi,
Imagine that i'm in photoshop for example. Once open, photoshop has a couple of toolbars and toolboxes.
When i create a new image or open an existent image it will open a new window, and that window, if resized will not get out of the main window.
How do i create such kind of window?
Thx,
Nuno
|
|
|
|
|
That is called an MDI application. There are lots of articles on how to create them.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I'm trying to find out how I can connect the reportviewer to a Datatable I created through the program.
my code:
DataTable DataForReport = new DataTable("DataForReport");
DataColumn Number = new DataColumn(); // function number
Number.DataType = System.Type.GetType("System.String");
Number.ColumnName = "NUMBER";
DataForReport.Columns.Add(Number);
DataColumn Descriptor = new DataColumn(); // function caption
Descriptor.DataType = System.Type.GetType("System.String");
Descriptor.ColumnName = "DESCRIPTOR";
DataForReport.Columns.Add(Descriptor);
DataColumn Quantity = new DataColumn(); // quantity sold
Quantity.DataType = System.Type.GetType("System.Decimal");
Quantity.ColumnName = "QUANTITY";
Quantity.DefaultValue = 0;
DataForReport.Columns.Add(Quantity);
DataColumn Sales = new DataColumn(); // gross sales amount
Sales.DataType = System.Type.GetType("System.Decimal");
Sales.ColumnName = "SALES";
Sales.DefaultValue = 0;
DataForReport.Columns.Add(Sales);
DataColumn Discount = new DataColumn(); // discount amount
Discount.DataType = System.Type.GetType("System.Decimal");
Discount.ColumnName = "DISCOUNT";
Discount.DefaultValue = 0;
DataForReport.Columns.Add(Discount);
DataColumn Net = new DataColumn(); // net amount
Net.DataType = System.Type.GetType("System.Decimal");
Net.ColumnName = "NET";
Net.DefaultValue = 0;
DataForReport.Columns.Add(Net);
DataColumn Cost = new DataColumn(); // cost price
Cost.DataType = System.Type.GetType("System.Decimal");
Cost.ColumnName = "COST";
Cost.DefaultValue = 0;
DataForReport.Columns.Add(Cost);
DataColumn Margin = new DataColumn(); // net amount
Margin.DataType = System.Type.GetType("System.Decimal");
Margin.ColumnName = "MARGIN";
Margin.DefaultValue = 0;
DataForReport.Columns.Add(Margin);
//make number the primary key in the table
DataColumn[] DataForReportKey = new DataColumn[1];
DataForReportKey[0] = DataForReport.Columns["NUMBER"];
DataForReport.PrimaryKey = DataForReportKey;
DataRow row;
row = DataForReport.NewRow();
for (int cnt = 0; cnt <= foundRows.GetUpperBound(0); cnt++)
{
string number = Convert.ToString(foundRows[cnt].ItemArray[10]);
string caption = Convert.ToString(foundRows[cnt].ItemArray[9]);
Decimal quantity = Convert.ToDecimal(foundRows[cnt].ItemArray[11]);
Decimal sales = Convert.ToDecimal(foundRows[cnt].ItemArray[12]);
Decimal discount = Convert.ToDecimal(foundRows[cnt].ItemArray[21]);
Decimal net = sales-discount;
Decimal cost = Convert.ToDecimal(foundRows[cnt].ItemArray[20]);
Decimal margin = net - cost;
DataRow rowfind = DataForReport.Rows.Find(number);
//does the table already contain the same?
if (rowfind == null)
{
//if not then add the record to the table
DataForReport.Rows.Add(number, caption, quantity, sales, discount, net, cost,margin);
}
else
{
//if the record exists then add the sales counters and store the new values
Int32 index = Convert.ToInt32(number) - 1;
DataForReport.Rows[index]["quantity"]
= quantity + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[2]));
DataForReport.Rows[index]["sales"]
= sales + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[3]));
DataForReport.Rows[index]["discount"]
= discount + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[4]));
DataForReport.Rows[index]["net"]
= net + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[5]));
DataForReport.Rows[index]["cost"]
= cost + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[6]));
DataForReport.Rows[index]["margin"]
= margin + (Convert.ToDecimal(DataForReport.Rows[index].ItemArray[7]));
}
}
return DataForReport.Rows.Count; //return the number of records
now I want the reportviewer to display the data as stored in the datatable DataForReports. How can I accomplish that?
hope someone can help me out
rgds
Frank
|
|
|
|
|
System.IO.File class have many functions..like move(),copy(),delete() etc etc.
but there are no Rename function.How can i rename a file(may be Doc file).
|
|
|
|
|
Hello,
The System.IO.FileInfo class has the "MoveTo" method for this casses.
System.IO.FileInfo fi = new System.IO.FileInfo("oldName");
fi.MoveTo("newName");
All the best,
Martin
|
|
|
|
|
Short explanation of the situation:
In my Form (main) i have embbeded a datagrid and a usercontrol with a panel inside on which i paint the names (nodes) of the datagrid.
for example in a treeview it would look like this:
food
+-meat
+-bread
###+-corn
###+-wheat
food can be bread or meat. On the panel of the usercontrol i draw then the food, the meat and the bread. Then i draw two lines to connect the food with the meat and the bread. Now i want to click on the bread and a contextMenu shouldappear with Next. When i click next it should repaint the panel with
bread
+-corn
+-wheat
To do so i need to go back to the datagrid and select the bread there. I have allready a method which selects me the right cell when i give it the text which item should be selected (here the string: bread). But here is my problem.
How do i send a message form the usercontrol to the form.
I was thinking it should work somehow with an event.
But i don't know exactly how to do it or where to start.
(Something like observer pattern)
I make an event in the usercontrol.
And the Form should notice it when the event is executed.
i thought on something like this:
in usercontrol:
public event EventHandler next = null;
and in the form:
usercontrol.next +=new EventHandler(usercontrol_back)
and then the handler for it.
private void usercontrol_next(object sender, EventArgs e)
{
//the method i need to call
}
but how do I say in my usercontrol that the event should be fired or started?
How does my form notice that the event is fired in my usercontrol?
And how do i get the string from the usercontrol to my datagrid (in the form)?
|
|
|
|
|
|
I am working on a COM dll in C# that needs to pass an ADODB recordset back to
the calling VBScript. I believe I have everthing setup correctly, as the
calls work, and it looks like a recordset is returned, however, the recordset
is null or closed. What is the trick to passing a recordset back from C#?
The Call:
Set rs = CreateObject("Interface")
rs.Init "System", "ODBC", "user", "pass", "database", "server"
retVal = rs.DataImport("value")
C#:
using ADODB;
[Guid("C3C26A94-9639-43c4-B59C-E245C8A68D44")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface iInterface
{
[DispId(1)] bool DataExport(string OrderNumber, string
TrackingNumber, decimal Freight, decimal Weight, string ShipDate, string
ShipVia, string MiscNum);
[DispId(2)] bool DataVoid(string OrderNumber, string TrackingNumber,
decimal Freight, decimal Weight, string MiscNum);
[DispId(3)] Recordset DataImport(string OrderNumber);
[DispId(4)] void Init(string nameVal, string odbcVal, string
userVal, string passVal, string dbVal, string srvVal);
}
[Guid("EF8369F0-CF42-40b1-B3F3-0EC54CE73FF4")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Interface")]
public class PSIHeader:iInterface
{
public Recordset DataImport(string OrderNumber)
{
//misc stuff - create connection, query etc...
//Recordset creation and return
rs.CursorLocation = CursorLocationEnum.adUseClient;
rs.Open(query.ToString(), cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
return rs;
}
}
I have been using regasm to register the type library.
Thanks
|
|
|
|
|
hi, i need to know how i can exit from sub(method) in c#, i mean keywork like exit sub in vb.net
123
|
|
|
|