|
The 1st one is object instance related issue & then your VB.NET conversion code is right one. Your code looks like right one but something makes trouble. ok let me do something, you just send me the report page, i'll test & will make it run. It should not take more time here after any more.
Regards,
thatraja
thatraja@yahoo.com
|
|
|
|
|
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ocn As New System.Data.OracleClient.OracleConnection
Dim oda As New System.Data.OracleClient.OracleDataAdapter("select empno,ename from emp", ocn)
Dim ods As New System.Data.DataSet()
ocn.ConnectionString = "Data Source=orcl;User ID=scott;Password=pw;Unicode=True"
oda.Fill(ods)
Dim rptprint As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptprint.Load(Server.MapPath("Reports").ToString() + "\\CrystalReport.rpt")
'TextBox1.Text = ods.Tables(0).Rows(0).Item("empno") 'This is no error
rptprint.SetDataSource(ods) 'This is no error
CrystalReportViewer1.ReportSource = rptprint 'This is error of object instantiate.
'CrystalReportViewer1.DataBind()
''rptprint.PrintOptions.PrinterName = DefaultPrinterName()
''rptprint.PrintToPrinter(1, False, 0, 0)
'TextBox1.Text = DefaultPrinterName()
rptprint.Close()
rptprint.Dispose()
ocn.Close()
ocn.Dispose()
ods.Dispose()
oda.Dispose()
'Dim host As New System.Net.IPHostEntry
'host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables("REMOTE_HOST"))
'Dim strSystemName As String = host.HostName
'Dim strPrinterName As String = "Generic / Text Only"
'rptprint.PrintOptions.PrinterName = strSystemName + "\\" + strPrinterName
End Sub
Public Shared Function DefaultPrinterName() As String
Dim oPS As New System.Drawing.Printing.PrinterSettings
Try
DefaultPrinterName = oPS.PrinterName
Catch ex As System.Exception
DefaultPrinterName = ""
Finally
oPS = Nothing
End Try
End Function
End Class
This is what i have in default.aspx.vb file. I have :
1.one crystalreportviewer control
2.one button control
3.one textbox control
I have not yet used your code, because this object instance error is frustraing me.
Regards
Girish Sharma
|
|
|
|
|
Hi, i have checked code, the issue is you are closing & disposing the Report Document object in Button1_Click event which was created there. For that you should create the Report Document object in class & then close & dispose in Page_Unload event.
use the code
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
PrintMode="ActiveX" EnableDatabaseLogonPrompt="false" />
<asp:Button ID="Button1" runat="server" Text="Button" />
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Web
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim rptprint As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
rptprint.Close()
rptprint.Dispose()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ocn As New System.Data.SqlClient.SqlConnection
Dim oda As New System.Data.SqlClient.SqlDataAdapter("select * from Employees", ocn)
Dim ods As New System.Data.DataSet()
ocn.ConnectionString = "Data Source=RAJA;User ID=sa;Password=123;Initial Catalog=Northwind"
oda.Fill(ods)
rptprint.Load("C:\CrystalReport1.rpt")
rptprint.SetDataSource(ods)
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
crConnectionInfo.ServerName = "RAJA"
crConnectionInfo.DatabaseName = "Northwind"
crConnectionInfo.UserID = "sa"
crConnectionInfo.Password = "123"
CrTables = rptprint.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CrystalReportViewer1.ReportSource = rptprint
CrystalReportViewer1.DataBind()
ocn.Close()
ocn.Dispose()
ods.Dispose()
oda.Dispose()
End Sub
End Class Here i want to inform you another thing, you can see the property EnableDatabaseLogonPrompt="false" in the designer. This is used for skip the Logon prompt in run time. And then i put the code for assigning the Database logon in codebehind('For DB Login '/For DB Login block) for run time.
Hope you can solve the issues using this code. let me know your feedback.
Regards,
thatraja
|
|
|
|
|
Thank you for your replies. Yes now object error has been removed; but now i am getting further error :
Dim host As New System.Net.IPHostEntry
host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables("REMOTE_HOST"))
Dim strSystemName As String = host.HostName
Dim strPrinterName As String = "Generic / Text Only"
TextBox1.Text = strSystemName 'Here i am getting 127.0.0.1 not \\mymachine name as you said i.e. \\RAJA In my case it should be \\GIRISH (as this machine where i am using) or on another client machine it should be that client machine's name.
rptprint.PrintOptions.PrinterName = strSystemName + "\\" + strPrinterName
rptprint.PrintToPrinter(1, False, 0, 0)
So, i am getting error : (A new error windows pop up)
COMException was unhandled by user code
Invalid printer specified.
Troubleshooting tips:
Check the ErrorCode property of the exception to determine the HRESULT returned by the COM object.
Get general help for this exception.
Regards
Girish Sharma
|
|
|
|
|
I'm sorry i'm not well since last week with heavy fever that's i can't able to reply quickly. As per my coding, you will be get IP address instead of System name, i mentioned "\\RAJA" for just easy understand. Please mention which line error occurs? ok.
|
|
|
|
|
i dont want to hard code the printer name.
if i do so then it will print the report to same printer every time.
in my office there are 20 comp and each comp has printer connected to it.
i want to print to a printer which is connected to particular client.
thanks,
|
|
|
|
|
shrikant.kudlur wrote: i dont want to hard code the printer name.
It's just an example snippet. You can set default printer if you want. So you should change the code based on your need. That's all. You can find code for "Get/Set Default printer" in Google.
Cheers.
|
|
|
|
|
Here is my code
ReportDocument doc = new ReportDocument();
doc.Load(Server.MapPath("crystalreport.rpt"));
System.Net.IPHostEntry host;
host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables["REMOTE_HOST"]);
string strSystemName = host.HostName;
string strPrinterName = "Generic / Text Only";
doc.PrintOptions.PrinterName=strSystemName + "\\" + strPrinterName;
doc.PrintToPrinter(1,true,1,1);
i m getting this error:
System.Runtime.InteropServices.COMException: Invalid printer specified
at this line:
doc.PrintOptions.PrinterName=strSystemName + "\\" + strPrinterName;
i m geting the name of the system currect but i think i mad simple mistake in assigning printer name
plz help me
thanks in advance
|
|
|
|
|
This link will help you to resolve the issue.
Clickety[^]
|
|
|
|
|
|
But It's still working for me. Please try again. Try in different browsers.
|
|
|
|
|
Hi
I am using a ajax auto complete feature in my web application. There are 3 textboxes in a page and added AutoCompleteExtender to each one.. when user start typing letters in first text box it gets list from database and displays as a list. like that when user type some thing in second text box it should display a list by sending the first text box value as parameter to webservice method to get values from database. How can we pass the first text box value as a parameter to the webservice when user is in 2nd textbox.. am using C# and asp.net..
Advanced thanks
|
|
|
|
|
After logging into the screen using the login controls, how can I make sure that the user always gets redirected to page1 after a successfull login?
Thanks
|
|
|
|
|
Hi
try to use DestinationPageUrl property of login control.
Cheers
Prosanta Kundu
|
|
|
|
|
hello ,
i create text boxes dynamically.i can't get text box value in another button.iam sending my code
this is iam developing
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If textbox1.Text <> "" Then
CreateControl()
End If
End Sub
Private Sub CreateControl()
Dim i As Integer = 0
For i = 1 To 10
Dim txt As TextBox = New TextBox
' txt.ID = "txt" & i
txt.ID = "txt_" & i
txt.text="hello"
Session("text") = txt.ID
Panel1.Controls.Add(txt)
Next
End Sub
Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
Dim i As Integer
For i = 1 To 10
Dim txtCtrl As TextBox = DirectCast(Panel1.FindControl("txt_" & i), TextBox)
If txtCtrl.Text <> Nothing Then
MsgBox(txtCtrl.Text)
End If
Next
End Sub
here i can get text box values one by one.but i dont wont that.
here 10 text boxes are there,in which,i want one textbox value which is selected in number of text boxes.
urgently i want solution plz send reply to me
|
|
|
|
|
Hi
Could you please give more information. "Textbox is selected" ...
Thanks
Prosanta
|
|
|
|
|
Hello friends,
I have made a webservice in my solution file and accessing that server from my solution's test pages. Everything works fine..until i deployed it on the production server.
I have updated the references in the web.config and .disco files to point to the production servers webservice url.
But it is giving me error
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [Ip adderss]
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [Ip adderss].
what could be the cause of this problem and how can i overcome from it?
Thanks.
Amit
|
|
|
|
|
Hi,
the request seems to timeout. This can have several reasons. I would suggest the following:
1. Check if you can reach the server by using a browser etc...
2. Check if the webservice itself crashed. To do this connect to the production server and take a look into the logfiles (you are writing a log, do you?). Check the system events of the production server.
3. Use a tcp-Monitor to monitor the messages exchanged by service and client. Maybe the response is not in the way the client expects.
Regards
Sebastian
|
|
|
|
|
Thanks SeMartens,
i got the solution. i have made changes to the hosts file.
It is working now
Amit
|
|
|
|
|
am not sure what am missing something.
i have a page where i hide Panels and show them. So i have this javascript function
function HideFilter()
{
document.getElementById("<%= Panel1.ClientID %>").style.display = "none";
document.getElementById("<%= Panel2.ClientID %>").style.display = "none";
document.getElementById("<%= ImageButton3.ClientID %>").style.display = "none";
document.getElementById("<%= ImageButton2.ClientID %>").style.display = "";
return false
}
function ShowFilter()
{
document.getElementById("<%= Panel1.ClientID %>").style.display = "";
document.getElementById("<%= Panel2.ClientID %>").style.display = "";
document.getElementById("<%= ImageButton2.ClientID %>").style.display = "none";
return false
}
they hide Hide and show Buttons. The Problem here is that ImageButton2 does not appear. The problem is in the function HideFilter() it does not want to show the ImageButton2 and it gives me a JavaScript error.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Check if "ImageButton2.ClientID" generates the client id. May be ImageButton2 is not a server control, so the client ID generation is failing and giving you javascript error.
Check the generated Javascript to get a clear idea.
|
|
|
|
|
In your code behind, you might have written
ImageButton2.Visible = false;
If so, ImageButton2 will not render to HTML and hence will throw javascript error.
For first time load also, hide your ImageButton2 using javascript.
Hope this will solve your problem.
|
|
|
|
|
Today is one of those Days. I did not see it. Thanks for pointing it out.
Problem Solved.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
|
i will reply to you there way you did. but i hope the site Admin will take care of you.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|