|
How you are passing DataSet from Indian server to Netherlands server ?
|
|
|
|
|
yes
Yogesh Pekhale
pekhaleyogesh@gmail.com
|
|
|
|
|
|
Hi All,
I've got a GridView which I am using like Visual Studio's Local and Autos Windows. When I attempt to call the DeleteRow method (GridView.DeleteRow Method[^]), the program will not compile. Any ideas how to 'Clear' the GridView control? The GridView is unbound, and I am using Framework version 2.0.
Thanks,
Jeff
private void GridViewClear() {
for (int i = GridView.Rows.Count; i > 0; i--)
{
GridView.DeleteRow(i - 1);
}
}
|
|
|
|
|
Jeffrey Walton wrote: the program will not compile
R u getting any error ? can you explain in details.
You can try with ,
GridView.dataSource=NULL
|
|
|
|
|
Hi Abhijit,
It won't compile because it cannot find the method. Also, it is an unbound control.
Jeff
|
|
|
|
|
I am quickly becoming a master of what does not work (even though others recommend it). The following results in "Collection already belongs to a DataGridView control. This operation is no longer valid.":
for (int i = GridView.Rows.Count; i > 0; i--)
{
GridView.Rows[i - 1].Cells.Clear();
}
|
|
|
|
|
Thinking I'd be slick (and give up the look and feel of Visual Studio), I swirtched to a TreeView with two columns. The most recent reason the program will not compile is: "Cannot implicitly convert type 'string' to 'System.Windows.Forms.ColumnHeader'". Offending line of code is (from Designer.cs - at least it is not my code this time):
this.Name = "FrmMain"; The related warning before the error is "warning CS0108: 'ASN1View.FrmMain.Name' hides inherited member 'System.Windows.Forms.Control.Name'. Use the new keyword if hiding was intended."
Does it ever end with this language?
Jeff
|
|
|
|
|
Hi.
In C dll, there is a struct that contains an array of struct pointers. I do not know how to represent that in C#. That's my problem.
Here is the relevant C code:
struct vector
{
uint elem_count;
uint size;
int (*cmp)(const void *, const void *);
void *table;
};
typedef struct vector VECTOR;
#define CTABLE VECTOR
#define CSTATS VECTOR
struct cstream
{
int mode;
int byte_count;
uchar *buff;
int buff_len;
int buff_pos;
int bit_pos;
bool growable;
bool prepared;
CTABLE *table[2];
CSTATS *stats[3];
uchar last_mode;
int last_mode_offset;
};
And here is the C# code:
[UnmanagedFunctionPointer(CallingConvention.Winapi) ]
unsafe public delegate int cmp(IntPtr a, IntPtr b);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public struct VECTOR
{
public uint elem_count;
public uint size;
public uint elem_size;
[MarshalAs(UnmanagedType.FunctionPtr)]
public cmp cp;
public IntPtr table;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
unsafe public struct CSTREAM
{
public int mode;
public int byte_count;
public IntPtr buff;
public int buff_len;
public int buff_pos;
public int bit_pos;
public bool growable;
public bool prepared;
public VECTOR[2];
public VECTOR[3];
public byte last_mode;
public int last_mode_offset;
}
[DllImport("compr.dll")]
public static extern IntPtr screate();
[DllImport("compr.dll")]
public static extern IntPtr tcreate();
Now, I know how to get the IntPtr to a struct. For example:
MyClass.VECTOR stext = new MyClass.VECTOR();
IntPtr st = MyClass.screate();
stext = (MyClass.VECTOR)Marshal.PtrToStructure(st, typeof(MyClass.VECTOR));
However, I do not know how to represent, or work with, "CTABLE *table[2];" or "CSTATS *stats[3];" from the struct in C, in the C# struct (CSTREAM).
Does anyone know how to do this?
Thank you for any help.
|
|
|
|
|
how can i populate a combobx with to columns of a datatable?? [firstname] and [lastname]
|
|
|
|
|
You would do best to create a new column called FullName so you can set the DataTextField of the control and just make the table your data source.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi guys,
I have a app that reads data from sqlserver table and set them into textboxes. The data type of my table's columns are 'text'. The problem is that wen there is a empty field in my table, i get the error:
Unable to cast object of type 'System.DBNull' to type 'System.String'
anyone a idea????
|
|
|
|
|
You need to check it to see if it's a DBNull before you attempt to convert it. Suppose that you are using a DataReader, you could do this
if (!myDataReader.IsDBNull(0))
myText = myDataReader.GetString(0);
|
|
|
|
|
Pete O'Hanlon,
Thanx for your response, bud what if i don't use a datareader? and have only a select. this how my code looks like:
SqlCommand comm00 = new SqlCommand("select Cmp_nr from Companies where Cmp_name='" + companyName + "'", myconn);
companyName = (string)comm00.ExecuteScalar();
|
|
|
|
|
Use the IsNull SQL Command and convert it on the server.
Also, you should use parameters in your queries, not appending strings. Using parameters prevents your select statement being open to an SQL Injection attacks. (Said with a broad Scottish accent...)
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
For simple select statements such as this, I would use ISNULL in the sql command...
For example, using the code you included:
SqlCommand comm00 = new SqlCommand();
string commSQL = "SELECT ISNULL(Cmp_nr, '') AS Cmp_nr FROM Companies where Cmp_name=@cmpName";
SqlPararameter cmpParam = new SqlParameter("@cmpName", SqlDbType.VarChar, 50);
//note: 50 should be changed to the field length of your db field Cmp_name
cmpParam.Value = companyName;
comm00.Parameters.Add(cmpParam);
comm00.Connection = myconn;
comm00.CommandText = commSQL;
|
|
|
|
|
string companyName = "";
object result = comm00.ExecuteScalar();
if(result != DBNull.Value)
companyName = (string) result; That will work.
Also, use parameterized queries. Your code has a security hole and is prone to SQL injection attacks. See this article[^].
|
|
|
|
|
Djavid j wrote: SqlCommand comm00 = new SqlCommand("select Cmp_nr from Companies where Cmp_name='" + companyName + "'", myconn);
This query, in short, is devil's palace. I mean it is subject to SQL Injection attacks. Did you consider having it as a Stored Procedure instead?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Depends where the code is. Obviously, whatever construct you're using ( data reader, data table, etc ), you're not checking if it has data in it before you try to read it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have a class that inherits from the datagridview component and within this class i am setting the datasource. My problem isthat the datasource is very large and i get a System.OutOfMemory Exception. I want to prevent the rows from populating at designtime. My code is below:
<br />
public class MembersView:DataGridView<br />
{<br />
public MembersView()<br />
{<br />
this.DataSource = Customer.Instance.GetAllCustomers();<br />
}<br />
}<br />
I still want the designer to show my the columns. Ay suggestions?
-- modified at 16:02 Sunday 18th November, 2007
|
|
|
|
|
Check the DesignMode property
if(DesignMode)
DataSource = Dummy
else
DataSource = Customer.Instance.GetAllCustomers();
only two letters away from being an asset
|
|
|
|
|
I came across this little unknown facet of .net a few days ago and today I decided to build a sample application to test this out. I followed the instructions as to how to apply SNIP specified on this site: http://www.morganskinner.com/Articles/StrongNameIdentityPermission/[^]
When I called my assembly in an unsigned project, it failed to give me any warning and my method from my signed class library executed.
Is this is happening because the signed class library is running in full trusted zone ?
|
|
|
|
|
I create bitmap;
Bitmap myBitmap = new Bitmap(150, 50);
Graphics g = Graphics.FromImage(myBitmap);
And draw picture;
g.FillRectangle()
g.DrawString()
I use myBitmap.Save() method and show image using IMAGE component img.ImageUrl = "..."; property.
But I don't want to save image. How can I show bitmap without using save() function ?
Best Regards...
|
|
|
|
|
Have you tried Graphics.DrawImage ?
only two letters away from being an asset
|
|
|
|
|
Assign the bitmap to the Image property of the control.
Experience is the sum of all the mistakes you have done.
|
|
|
|