|
Ok, I am now able to add the column, but when I click the arrow, there is nothing in it. Here's my code so far:
private void _SetupLists()
{
_TableId = (int)cboTables.SelectedValue;
DataSet dsGrid = DataProcs.ExecuteQuery("SELECT ColumnId, TableId, ColumnName, Expression FROM Columns WHERE TableId = " + _TableId, CommandType.Text);
grdColumns.DataSource = null;
grdColumns.DataMember = null;
if (dsGrid.Tables[0].Rows.Count > 0)
{
grdColumns.DataSource = dsGrid.Tables[0];
grdColumns.Columns[0].Visible = false;
grdColumns.Columns[1].Visible = false;
grdColumns.Columns[2].Width = 200;
grdColumns.Columns[3].Width = 490;
}
DataSet dsTables = DataProcs.ExecuteQuery("SELECT TableId, QueryName FROM Tables ORDER BY TableName");
DataGridViewComboBoxColumn colTables = new DataGridViewComboBoxColumn();
colTables.Name = "colTables";
colTables.DataSource = dsTables.Tables[0];
grdColumns.Columns.Add(colTables);
}
Everything makes sense in someone's mind
|
|
|
|
|
hi.
I have a problem.
a section of a project I have created excel file to transfer data from the datagridview would. I then transferred the data after checking this information to the database I want to register. I assign the following code to add a record button.
string constr = "DSN=depo";
OdbcConnection con = new OdbcConnection(constr);
string firma = dataGridView2.SelectedRows[0].Cells["firma_ad"].ToString();
string miktar = dataGridView2.SelectedRows[0].Cells["miktar"].ToString();
for (int i = 0; i < dataGridView2.Rows.Count; i++)
{
con.Open();
OdbcCommand cmd_ec = new OdbcCommand();
OdbcDataAdapter adapter_ec = new OdbcDataAdapter();
string sql_ec = "insert into siparis (firma_ad,miktar)values ('" + firma + "','" + miktar + "')";
OdbcDataAdapter adpt_ec = new OdbcDataAdapter(sql_ec, con);
DataSet dsett_ec = new DataSet();
adpt_ec.Fill(dsett_ec, "Firmaya_göre_parçaları belirle");
con.Close();
But it also said there is an error in the code. excel file with this code when processing the same record over and over again until my yaıt line goes. Add the information in the same row is continuous.
Please let me know solution for my problem. How do I need to follow a path?
Thanks.
|
|
|
|
|
dr_move wrote:
string sql_ec = "insert into siparis (firma_ad,miktar)values ('" + firma + "','" + miktar + "')";
just check the format of the sql statement first...
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
is there any class that converts in different number system?
|
|
|
|
|
Hi,
numbers don't have a base, it is only when they are converted to/from strings that a base applies.
have a look at Convert.ToInt32(String, Int32) and Convert.ToString(Int32, Int32)
[and similar for other types]
|
|
|
|
|
no. i mean what if i want to convert FFFF to binary or octal or any other format?
|
|
|
|
|
you can convert "FFFF" to an int32 and then to "1111111111111111" or "00000000000000001111111111111111" with the methods I indicated earlier.
or you can write your own code to convert one string in another, which is harder to do, and does not really offer any advantage.
|
|
|
|
|
FFFF is already in the desired "format". You just need to choose the correct string format so you can see it in the desired representation.
Int32 i = 200;
String oct = Convert.ToString(i, 8);
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
|
|
I have developed a windows application. I put a rectangle picture as a background picture for my form. In that picture, outside the rectangle, it is colored red. In my form I set that color as the transparency color so it would show only that rectangle or any other shape as a form.
It works well in my own computer, but whenever I try to use it in another computer which also has the .Net framework installed there, the color does not hide and the transparency does not work. It shows both the rectangle and the background color. What should i do?
the picture is saved as BMP.
I'm using C# in a Visual studio. The application is written in .Net 2.0.
|
|
|
|
|
A program cannot behave like this….Better you review your code. You can also post your code snippets for getting better suggestions from the forum.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hey, i've been looking for an effective method of storing 2 byte values within one. Or, two short values within one.
The system I currently use is by embedding an unsafe code to point to a byte value and to cast the relevant data. Here's an example:
byte db, v1, v2;
v1 = 50;
v2 = 80;
unsafe
{
byte* db_p = &db;
db_p[0] = (byte)((v1) >> 2);
db_p[1] = (byte)(((v1) << 6) | (((v2) >> 4)&0x3F));
db_p[2] = (byte)((v2) << 4);
}
Which stores two values excellently. However, For values below 4 generally, numbers tend to overlap each other. IE, values of v1 = 0, v2 = 0; and v1 = 1, v2 = 1; tend to have the same digit value of db .
I was wondering there were any other methods of storing 2 values of data (bytes) within one single data (I'm using this to remove the necessity for multi-dimensional arrays and large collection objects).
Thank you!
|
|
|
|
|
1. this isn't C# code is it? hence: wrong forum.
2. db_p is a pointer pointing to a byte, yet you write at locations db_p+0, db_p+1, db_p+2, so you write past the item your pointer points to, which is either not allowed (C#) or cheating (C/C++).
3. Of course you can store 2 byte values in 3 bytes; it is plain stupid.
|
|
|
|
|
Well i'm sorry but i'm not entirely experienced with the whole "storing two values in one".
I came here asking for help, not asking to be told i'm stupid and the methods i'm using are stupid..
That post didn't help at all, does anyone else have any real experience in storing data values inside one variable?
Thanks
|
|
|
|
|
when I said "storing 2 byte values in 3 bytes is plain stupid." I can assure you it is, as that isn't compression at all, if anything it is expansion.
Epoque wrote: i'm not entirely experienced with the whole "storing two values in one"
Nobody is, as it can't be done. If you could store two byte values in one byte (i.e. store two byte values and then retrieve those values in any order and as often as you'd like), then what would keep you from doing that recursively: you could store the first two bytes of anything in 1, the next two bytes in another one, then combine those two bytes into a final byte; in the end you could store any amount of data, why not the entire Internet, into that one final byte?
We do get lunatics asking such questions regularly.
OTOH one of the replies you posted earlier in this thread seems to indicate an entirely different problem: storing one (or N) values for a 2D collection of cells. That can easily be solved in many ways:
1. with N two-dimensional arrays
2. with N one-dimensional arrays, and linearizing the index (as in index = x + y * width )
3. with a single one-dimensional array holding a little struct, which holds the different values for a single cell.
If that is what you need, then you should have made that clear from the start.
|
|
|
|
|
No offense, but your code is odd.
Now of course you can store multiple values in one variable, but they'll be smaller.
Example:
static byte CombineBytes(byte a, byte b)
{
return (byte)((a & 15) | (b << 4));
}
A and B can only be zero through 15 though, obviously.
To get them back:
byte a = (byte)(x & 15);
byte b = (byte)(x >> 4);
warning: all code here is untested. (but really it is just about the idea, not the actual code)
|
|
|
|
|
Thank you for this.
Let's say I want to store a value greater than 15, would it be plausable to use a "short" value instead, to increase the available range of data?
And, would each of the values produced be unique, or would they intersect at some point with conflicting values?
Thank you for your help.
|
|
|
|
|
It just divided the byte in two parts, you could do the same with a short (then you could fit in two complete bytes) or an int (then you could fit in 2 complete shorts or 4 bytes)
But if you want a 2D -> 1D mapping it's better to use something "sane" such as x + y * width or if you don't want to use width you could use morton numbers to get a Z curve (just interleave the bits of your indices)
|
|
|
|
|
Just out of interest; why would you want to do this?
|
|
|
|
|
Well, I plan on having a 2D plain with cells ranging from 15x15 to up to 300x300, and rather than using a library collection storing both values, I would prefer to have both values point to an index within an array.
IE, R1C1 => Index 1, R1C2 => Index 2 etc etc..
I have read that these are possible but with no solutions.
|
|
|
|
|
Seriously? Do you mean:
index = x + y * width
That's pretty much basic knowledge.. so I suspect you mean something else, but then what do you mean?
|
|
|
|
|
Well, let's say each cell has a corresponding slot in an array containing information about the cell.
Each cell, when clicked or managed, will refer to the single slot in an array corresponding to the co-ordinates or row,column values.
If I was to use a method that relies on adding or multiplying x and y, there are chances that two cell coordinates may intersect and point to the same object. Therefore, I need the mathematical formula that produces an output using x and y to be a unique index key (not too large, otherwise the array would consume considerable amounts of memory), so that it may point to a slot in the array of cell information.
1,1 => Slot 1 in the array
1,2 => Slot 2 in the array
2,1 => Different slot than '1,2'.
Thank you 
|
|
|
|
|
Yes that's why you multiply y by the width
|
|
|
|
|
I'm confused about what the value of 'width' should be. If width is the size of the cell, then I get conflicting types.
When I ran a debug loop doing (x + y * 16) I received conflicts at 17,1 17,2 etc etc.
And if I use 300 as the width, then the size of the array will be equal to 90,300 which is rediculously massive. Considering each slot in the array will store a structure of information, that could be quite a massive amount of memory usage?
|
|
|
|