|
I'm Using the following code to get the Que and wait times for a place I work for. If i open the address in a normal window im asked for my user name and pw. then i can see .xml file. But when i used the code below i get the error that follows it. I know it needs to some how have the credentials. This tool also has multiple web browsers logged into the same main site. and if i use any links within those browsers i don't even have to use my user name pw. Is there a way to just use the credentials automatically from say webbrowser1 and use them on this to make it authorize? If not can someone show me how to add the credentials so it will not 401 error. I wrote the app to be used by multiple people so the credentials are not always the same but always be what ever they used on webbroser1. I know my code reads the XML right because i saved it to my computer to use for testing. But ill be damned i if i can find the code I need to add in credentials. If someone could show me how to add them for this. im sure i probably figure out how to grab them from another window to be used here. Again im a total newbie on vb. I picked it because back in the day C64 I wrote basic lol. and realized it was something I could for simple things wrap my head around.
Dim que As XmlTextReader
que = New XmlTextReader("http://tracker.telenetwork.com/callmonitor/assist.xml")
'Used next line to test with Copied version from server to make sure xml reader worked.
'que = New XmlTextReader("c:\\xml\assist.xml")
que.Read()
que.Read()
Dim result = que.GetAttribute("queue")
MsgBox(result)
result = que.GetAttribute("maxwait")
MsgBox(result)
The remote server returned an error: (401) Unauthorized.
System.Net.WebException was unhandled
Message="The remote server returned an error: (401) Unauthorized."
|
|
|
|
|
What authentication method or methods is the
http://tracker.telenetwork.com server expecting
you to use?
You could maybe provide authentication credentials
something like this (C#, sorry )...
WebClient webClient = new WebClient();
webClient.Credentials = CredentialCache.DefaultCredentials;
XmlTextReader que = new XmlTextReader(webClient.OpenRead(new Uri("http://tracker.telenetwork.com/callmonitor/assist.xml", UriKind.Absolute)));
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am very new in multithreading. I tried to read some topics but confused with different synchronization techniques used in .net multithreading like Mutex class, semaphore, critical section, event, wait handle and monitor.
Can any body guide me or can we do online conference or is there any in-depth video tutorial in multithreading ?
|
|
|
|
|
This will help Multithreading in .NET[^]
I will also add that WinForm / WPF, they are both thread unsafe and work on the UI thread (the one started in Program.Main() with a Run() method which act as a Window message pump).
To send message on the UI thread both (WinForm) Control and (WPF) DispatcherObject have a method called BeginInvoke().
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
You surely would be interested in this:
http://www.albahari.com/threading/part4.aspx[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi
I having a problem when I create a simple function and I try to pass n parameters
These is the code:
public double TestFunction(params Object[] YourCells)
{
return 0;
}
This is shows on excel and I can use on the Insert Formula, but when Excel interprete is give to me the #VALUE! error
This is the formula on excel cell: =TestFunction(C2,F2)
Shows everything fine.
Can anyone please help me.
Visual Studio 2008, Excel 2007.
Thanks
|
|
|
|
|
Ok, I have never understood this. Its an interface and therefore has no code in it...only 'stubs'. So when you implement it, it generates the Dispose method...and the Dispose method has code in it...how does this work? Id like to have my interface do something like this.
for example, create a class and implement IDisposable, press enter and it will generate the following VARIABLES and code blocks, not just empty subs.
Private disposedValue As Boolean = False ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: free other state (managed objects).
End If
' TODO: free your own state (unmanaged objects).
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
#Region " IDisposable Support "
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
It's simple. The interface says that the object can be disposed before all references to it dies. The interface only says that.
But, the common all-purposes implementation (the Dispose pattern) says that:
Dispose() methods calls a virtual method Dispose that receives a boolean (true) and then calls GC.SuppressFinalize(this) and the destructor calls Dispose(false).
So, if you want your code to have somme implementation, you will at least need to implement a class (say MyDisposable) that implements IDisposable (so the using keyword can work with it) and implements Dispose to call:
Dispose(true);
GC.SupressFinalize(this);
And then, you make only the Dispose(disposing) virtual.
You can even make your "only call once" approach inside the non-virtual Dispose().
|
|
|
|
|
I dont know if I'm misunderstanding, or if maybe i posted my qustion wrong...basicly im trying to figure out something like this (VB)
public interface ISomeInterface
sub DoSomeStuff()
end interface
now when a sub class implements this i want DoSomeStuff() to have code already in it
public class MyDoSomeStuffClass
implements ISomeInterface
private mCanDoStuff as boolean = true ***i want this to be generated***
public sub DoSomeStuff() Implements ISomeInterface.DoSomeStuff
***Start Generated***
if mCanDoStuff Then
msgbox("WoOT")
End If
***end generated***
end sub
end class
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
Polymorpher wrote: ***i want this to be generated***
I would ask on the Visual Studio board[^]...
There's probably an easy way to make a macro or something
that does this....I have no experience with that.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It's impossible.
Interfaces only says: The method exist.
You can, of course, do:
IMyInterface
(with some methods)
BaseClassThatImplementsIMyInterface
A class with virtual methods that implements the interface and, so, can create the basic functionality.
You can also create a helper class.
For example:
IMyInterface -> MyMethod
If your class comes from some other base class, it can implement IMyInterface and, in MyMethod, call
MyInterfaceBasicImplementation.MyMethod()
And, finally, you can create extension methods using interfaces.
So, for example:
IDictionary has the TryGetValue method.
I implemented a method called GetValueOrDefault as an extension method. It is NOT virtual, but as the TryGetValue is, it is enough for me.
|
|
|
|
|
It's not impossible, IDisposable does it. There is a way to do it, im just trying to figure out what that way is.
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
I think it is implemented using the CodeDOM. Visual Studio will be calling a custom code generator for inserting that snippet of code. Can't find it though. Found the stuff for generating the default constuctor code, typed datasets, and all sorts by using reflector, but not Dispose. Must be hidden away in the bowels of the framework.
A good article on using the CodeDOM can be found here[^]
|
|
|
|
|
Thanks!
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
Hey,
I'm creating a .Net download library. Part of the reason I'm doing this is to learn more about mulithreading. I've run into some things now that I'm not really able to solve, and can't find answers to, since it's pretty specific. I think my problems could be resolved after 15 to 30 mins of help by someone experienced with the involved aspects. If anyone feels like helping me out, please contact me.
# Email: jeroendedauw at gmail dot com
# Skype: rts.bn.vs
# Xfire: bn2vs
# Msn: jeroendedauw at gmail dot com
# Google talk: jeroendedauw
Cheers!
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
Come on, you've been a member long enough to know how it works. Post a piece of code, describe the problem and get an answer.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Indeed. I know that. But if you try something a few times, at multiple locations, and it fails, you should think of changing tactics, no?
My problem is more then 3 lines of code, and I really think I can't post it all here. Furthermore, since I'm not really sure on how to solve my problem, I can't determine which are all the relevant parts.
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
jeroen de dauw wrote:
My problem is more then 3 lines of code, and I really think I can't post it all here
is sort of different from your OP,
jeroen de dauw wrote: I've run into some things now that I'm not really able to solve, and can't find answers to, since it's pretty specific
To be honest, you seem to be strugglng to even explain the problems, which does make it difficult to help. I can't honestly see anyone contacting you direct under any circumstances, but particularly as you haven't really explained what is wrong.
Anyway, good luck
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
hi all, i need to export lakhs of records to excel, if i use the following code means, it doesn't throws any error,
select top 50000 * from dbo.CustomerDetail
but instead if i use
select * from dbo.CustomerDetail (it contains more than 10lakhs of records), it throws me an error.... Significant loss of functionality - the workbook contains data in cells outside of the row and column limit. data beyond 256(IV) columns by 65,536 rows will not be saved.....
my need is, if i have a table, it contains 70,000 records, i need to export it to excel, at that time it should automatically split the datas to two worksheets (which means 65000 in sheet1 and remaining 5000 in sheet2)...
code snippet in vb.net:
Imports Microsoft.Office.Interop.Excel
Imports System.Data.SqlClient
Imports System.Threading
Public Class Form1
Dim dtstart As DateTime = DateTime.Now
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strUniqueParamId As String
strUniqueParamId = System.Guid.NewGuid().ToString
Dim xThread As New Thread(AddressOf excelcheck)
xThread.Name = strUniqueParamId
xThread.Start()
MessageBox.Show("Generating")
Timer1.Start()
Thread.Sleep(1700)
'MessageBox.Show(Environment.TickCount.ToString());
End Sub
Sub excelcheck()
' Create the Excel Application object
Dim excelApp As New ApplicationClass()
' Create a new Excel Workbook
Dim excelWorkbook As Workbook = excelApp.Workbooks.Add(Type.Missing)
Dim sheetIndex As Integer = 0
Dim col, row As Integer
Dim excelSheet As Worksheet
Dim sqlcon As New SqlConnection("server=SHRIGI104\SHRIUNO0301;database=Test;uid=sa;pwd=welcome3#;")
sqlcon.Open()
Dim ds As New DataSet
Dim Da As New SqlDataAdapter()
Dim sqlcmd As New SqlCommand
sqlcmd.CommandType = CommandType.StoredProcedure
sqlcmd.CommandText = "SampleExcel"
sqlcmd.Connection = sqlcon
Da.SelectCommand = sqlcmd
Da.Fill(ds)
sqlcon.Close()
' Copy each DataTable as a new Sheet
For Each dt As System.Data.DataTable In ds.Tables
sheetIndex += 1
' Copy the DataTable to an object array
Dim rawData(dt.Rows.Count, dt.Columns.Count - 1) As Object
' Copy the column names to the first row of the object array
For col = 0 To dt.Columns.Count - 1
rawData(0, col) = dt.Columns(col).ColumnName
Next
' Copy the values to the object array
For col = 0 To dt.Columns.Count - 1
For row = 0 To dt.Rows.Count - 1
rawData(row + 1, col) = dt.Rows(row).ItemArray(col)
Next
Next
' Calculate the final column letter
Dim finalColLetter As String = String.Empty
Dim colCharset As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim colCharsetLen As Integer = colCharset.Length
If dt.Columns.Count > colCharsetLen Then
finalColLetter = colCharset.Substring( _
(dt.Columns.Count - 1) \ colCharsetLen - 1, 1)
End If
finalColLetter += colCharset.Substring( _
(dt.Columns.Count - 1) Mod colCharsetLen, 1)
' Create a new Sheet
excelSheet = CType( _
excelWorkbook.Sheets.Add(excelWorkbook.Sheets(sheetIndex), _
Type.Missing, 1, XlSheetType.xlWorksheet), Worksheet)
excelSheet.Name = dt.TableName
' Fast data export to Excel
Dim excelRange As String = String.Format("A1:{0}{1}", finalColLetter, dt.Rows.Count + 1)
excelSheet.Range(excelRange, Type.Missing).Value2 = rawData
' Mark the first row as BOLD
CType(excelSheet.Rows(1, Type.Missing), Range).Font.Bold = True
excelSheet = Nothing
Next
' Save and Close the Workbook
excelWorkbook.SaveAs("C:\BCP\sss.xls", XlFileFormat.xlWorkbookNormal, Type.Missing, _
Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, _
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
excelWorkbook.Close(True, Type.Missing, Type.Missing)
excelWorkbook = Nothing
' Release the Application object
excelApp.Quit()
excelApp = Nothing
' Collect the unreferenced objects
GC.Collect()
GC.WaitForPendingFinalizers()
MessageBox.Show("Genearted Sucessfully")
Timer1.[Stop]()
Dim dtEnd As DateTime = DateTime.Now
Dim ts As TimeSpan = dtEnd - dtstart
MessageBox.Show("Mins:" + ts.Minutes.ToString() + "" + "Secs:" + ts.Seconds.ToString())
End Sub
End Class
Sample Stored Procedure:
USE [Test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE [dbo].[SampleExcel]
AS
BEGIN
select top 50000 * from dbo.CustomerDetail
select top 50000 * from dbo.CustomerDetail
select top 50000 * from dbo.CustomerDetail
select top 50000 * from dbo.CustomerDetail
select top 50000 * from dbo.CustomerDetail
select top 50000 * from dbo.CustomerDetail
END
GO
the above sp should be re-written as in single select statement
like "select * from dbo.CustomerDetail"....
pls need the help very soon...
modified on Thursday, December 10, 2009 6:42 AM
|
|
|
|
|
1. Having that much records in an excel file! Why?
2. Why are you using interop? You can connect to the excel file through OleDb Connection and export everything to it through one insert command.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Well, your choices are to change your proc to select all the data and put some loop method in your code to output 65,000 records per sheet and start a new sheet, OR use dynamic sql to generate the appropriate number of selects and then execute them within the stored proc. I assume your table has a unique key that you can use to control the selection of each 50,000 rows?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
You may want to do a little test first to see how much of your data you can actually fit in a WORKBOOK, not a worksheet.
Yeah, you're going to exceed the number of rows available in a single sheet, and that's handled with a bit of work on your part. But, you're bigger problem is that you're probably going to run Excel out of memory before you get through all of your customers.
The test is easy. Take a small sample of records from your database and export them to an Excel sheet. Then copy and paste those records over and over again filling up the sheet as much as possible. Then create a new sheet and paste the records into that, filling up the sheet as much as possible. I think you'll find that you run Excel out of memory fairly quickly and long before you get through all of your customers.
|
|
|
|
|
I'm not sure about the memory issues, as a powerful enough machine should solved that problem, however it sounds as if you are using Excel 2003.
Excel 2003 is limited to 65,536 rows by 256 columns per worksheet. The number of worksheets is only limited by available memory.
If you move to Excel 2007 you can go up the the limit of 1,048,576 rows by 16,384 column per worksheet, with the number of worksheets is limited by available memory.
So either loop and create multiple sheets, or upgrade to 2007. Either way ensure you have a shed-load of memory available.
Excel 2003 Limits[^]
Excel 2007 Limits[^]
|
|
|
|
|
How to retrieve an email using pop3??There is no class pop3 and what is the best method??
|
|
|
|
|
You could have tried this[^] first, and read through some of the suggestions available.
|
|
|
|
|