|
Hello
i am getting muliple instances warning on the following line:
DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + ServerName + "/w3svc");
how can I getrid of this?
-adnan
|
|
|
|
|
I have a problem with this code. I am reading a value from a SQL Server and try to check it.
<br />
while(rdr.Read())<br />
{<br />
if(rdr.GetSqlValue(4)==1)<br />
{<br />
ArrayMandant.Add(rdr.GetString(0) + "#" + rdr.GetString(1) + "#" +<br />
rdr.GetString(2) + "#" + rdr.GetString(3) + "#" +<br />
rdr.GetValue(4).ToString() + "#" + rdr.GetString(5));<br />
}<br />
}<br />
I get a build error. Operator "==" cannot be used on objects and int. How I am able to check this value ?
|
|
|
|
|
You could either use a method of the SqlDataReader class that already returns an integer:
if (rdr.GetInt32(4) == 1)
or cast the return value of GetSqlValue .
if (((int) rdr.GetSqlValue(4)) == 1)
www.troschuetz.de
|
|
|
|
|
Hi,
You are getting that error because GetSqlValue is returning an object and you are trying to compare it with an int. Trying using GetSqlInt32 to get the column value instead of GetSqlValue.
Thanks
SGS
|
|
|
|
|
Hello c# professionals,
I would like to customize my data grid like a SQL Server database table.This means when I press the ENTER key the cursor must move to the next cell.And when the cursor at the last column of the row and by pressing the ENTER key the cursor must move to the next line and first column..
Can anyone help?
|
|
|
|
|
I would to add to the default Windows context menu (copy/cut/delete/cancel) (that appear when the user right-click inside a textbox) a new voice during my software' installation.
If that voice is pusshed it calls my software passing a "pointer" to that textmenu, so i can set its text with what i want.
How can i do? I know to use Windows Shell integration, but where can i found these insformation? Iìve serched in google, msdn and in codeproject but i've founded nothing?
Please answer me becouse it is important.
Thanks
|
|
|
|
|
Hi guys !
would be very thankful if somebody suggested what is happening here and how i can resolve
this issue. the problem is that iam encrypting and sending messages over the LAN with
tcpclient stream class. on the receiving end i am trying to decrypt the message but a get a
whole set of different characters
no where near the source message
iam using
client.GetStream().EndRead(ar);
followed by
Encoding.ASCII.GetString(readBuffer, 0, BytesRead - 1);
thanks in advance
manishjadhav
|
|
|
|
|
|
hi colin thanks very much for the quick response.
i am using ASCII encoding right now on the server side but i have tried unicode as well but the characters still get tampered. please guide
thanks
|
|
|
|
|
Hi
When i open a .tif file in picture box, i should be able to see or open all the pages. A .tif file can have any number of pages. I should be able to display all the pages in the picture box one by one. How can i do this?
I also need to zoom in and zoom out the image. Also scrolling of the image.
Can anyone help me? If possible please send me the code to open multiples pages of .tif files, zoom in and zoom out of image and scrolling of image.
|
|
|
|
|
you need to iterate through the tif file to get each individual image -
<br />
System.Drawing.Image i = System.Drawing.Image.FromStream(mem);<br />
int count = i.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);<br />
for (int x = 0 ; x < count ; x++)<br />
{<br />
i.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page,x);<br />
Bitmap bmp = new Bitmap(i, i.Width / 2 * 140 / 100, i.Height * 140 / 100);<br />
}<br />
Then if you want to zoom the easiest way is probably just to change the width and height of your image.
|
|
|
|
|
Thanks a lot for this help.
can you tell me how can i display the corresponding frames in the picturebox?
right now the first page gets displayed. when i press the "next" button, i need the second page to be displayed in the picture box.
|
|
|
|
|
<br />
System.Drawing.Image i = null;<br />
int imageIndex = 0;<br />
<br />
public myForm()<br />
{<br />
System.Drawing.Image i = System.Drawing.Image.FromStream(mem);<br />
i.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page,imageIndex);<br />
myPictureBox.Image = i;<br />
}<br />
<br />
private void button_Click(object sender, System.EventArgs e)<br />
{<br />
if(imageIndex >= i.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page))<br />
{<br />
MessageBox.show("Reached end of images in tif");<br />
return;<br />
}<br />
imageIndex++;<br />
i.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page,imageIndex);<br />
myPictureBox.Image = i;<br />
}<br />
You may have to update or refresh the pictureBox (but i dont think so)
|
|
|
|
|
Hi
Thanks a lot. I have got the solution. I used a static variable and did it.
Can i have your personal id? This is incase of future help?
|
|
|
|
|
I dont know how helpful I could be (I can try but I think there are many more bright people here on cp!) but you are welcome to contact me via email if you need help with something - gavirj2002 at yahoo.co.uk
|
|
|
|
|
hi!
How could i implement delay in c#? that will logicallylook like this:
while<br />
{<br />
process1();<br />
delay(5);<br />
}
thanks!!!
|
|
|
|
|
Use the Thread.Sleep() method.
Regards
Senthil
|
|
|
|
|
Thanks Senthil!!!
|
|
|
|
|
wanna explore this
any sample code for this topic.....
thanx in advance
|
|
|
|
|
Hi ronin,
You can access the database from the webservice in the same way you access from the other applications. The following lines of code connect to the database and return the results in the form of a dataset.
[WebMethod]
public DataSet GetData()
{
SqlConnection conn = new SqlConnection();
string connstring = "Persist Security Info=false; Integrated Security =false; database=DATABASENAME; server=DATABASESERVERNAME; User ID=USERID; Password=PASSWORD";
conn.ConnectionString = connstring;
DataSet ds = new DataSet("Employee Data Set");
SqlDataAdapter adptr = new SqlDataAdapter("select * from TABLE NAME", connstring);
adptr.Fill(ds);
return ds;
}
Hope this will help you.
Regards
SGS
|
|
|
|
|
The above reply seems to be fine I would like to add some details. Please do take care connection string settings and securtiy
Padvit
|
|
|
|
|
i have created a server and client application.
i have ran the server but after a few days of running, it seems to utilize almost 100% of the processor, is this a problem of memory allocation (memory leaks)? if so, what should i do to address this problem? what are the tools which can be used to check if there exists any memory leaks?
|
|
|
|
|
100% utilitization of the processor probably means that there are a lot of threads running around. If you're looking to measure memory consumption, look for Memory Usage and related columns in Task Manager.
Regards
Senthil
|
|
|
|
|
threads seems like a valid reason for 100% cpu
@topic
maybe it's not even the memory itself that's leaking but the thread-resources...
make sure every thread is properly killed (thread.Abort()) after it's done (on WinAPI it really is necessary to do this every time, not sure if the GC collects finished threads so just make sure it's cleaned up)
since you have a client-server-model I guess you're using threads and "sessions" for each user. make sure every session has an inactivity-timeout and it's properly cleaned up (all the threads, all the resources)
so long.
|
|
|
|
|
My application allows user to authenticate to a remote share using domain loggon by invoking mpr.dll
[DllImport("mpr", CharSet=CharSet.Auto)]<br />
public static extern int WNetAddConnection2(<br />
ref NETRESOURCE lpNetResource,<br />
[MarshalAs(UnmanagedType.LPTStr)]<br />
string lpPassword,<br />
[MarshalAs(UnmanagedType.LPTStr)]<br />
string lpUserName,<br />
int dwFlags<br />
);
For example I logged on using following user name: "DOMAIN_1/USERNAME_1".
I would like to find out the user groups (Administrators/Users/etc. ) of user USERNAME_1 within DOMAIN_1.
Could anyone please suggest how to do that?
I have tried using NetUserGetLocalGroups() (netapi32.dll) function but it only retrieved the user groups of USERNAME_1 in the local machine, not in the domain DOMAIN_1. I've tried NetUserGetGroups() too but don't know how to set the parameters to get it right. Please help.
[DllImport("netapi32", CharSet=CharSet.Auto)]<br />
public static extern int NetApiBufferFree(<br />
out IntPtr bufptr <br />
);<br />
<br />
[DllImport("netapi32", CharSet=CharSet.Auto)]<br />
public static extern int NetUserGetLocalGroups(<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string servername,<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string username,<br />
int level,<br />
int flags,<br />
out IntPtr bufptr,<br />
int prefmaxlen,<br />
out int entriesread,<br />
out int totalentries<br />
);<br />
<br />
<br />
public static ArrayList GetUserGroups(string serverAddress, string userName)
{<br />
<br />
ArrayList groupNames = new ArrayList();<br />
int entriesRead = 0;<br />
int totalEntries = 0;<br />
<br />
IntPtr bufPtr;<br />
<br />
int errorInfo = NetUserGetLocalGroups(serverAddress,userName,0,LG_INCLUDE_INDIRECT,<br />
out bufPtr,MAX_PREFERRED_LENGTH,out entriesRead,out totalEntries);<br />
<br />
<br />
<br />
if(entriesRead> 0)<br />
{<br />
LOCALGROUP_USERS_INFO_0[] RetGroups = new LOCALGROUP_USERS_INFO_0[entriesRead];<br />
IntPtr iter = bufPtr;<br />
for(int i=0; i < entriesRead; i++)<br />
{<br />
RetGroups[i] = (LOCALGROUP_USERS_INFO_0)Marshal.PtrToStructure(iter, typeof(LOCALGROUP_USERS_INFO_0)); <br />
iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LOCALGROUP_USERS_INFO_0)));<br />
groupNames.Add(RetGroups[i].groupname);<br />
}<br />
int error = NetApiBufferFree(out bufPtr);<br />
}<br />
<br />
if (errorInfo != NERR_Success)<br />
{ <br />
int error = NetApiBufferFree(out bufPtr); <br />
}<br />
<br />
return groupNames;<br />
}
|
|
|
|