Tuesday, 27 March 2012
connect to sql
I have two machine one is application server (asp) and one is database
server (sql 2000).
Between them, I use a crossover cable connect each other(1GB) and also they'
re all connect to internet use another network card(100 MB).
I test locally and the speed is good, but just found it's very slow after we
moved the machined to the collocation. How to trouble this? Please help.
just found out use name instead of ip and change from to SQLOLEDB
provider=SQLOLEDB.1 and it works fine.
why is that? please advice.
<js@.someone.com> wrote in message
news:eyKXm6r8GHA.4708@.TK2MSFTNGP05.phx.gbl...
> Hi
>
> I have two machine one is application server (asp) and one is database
> server (sql 2000).
> Between them, I use a crossover cable connect each other(1GB) and also
they'
> re all connect to internet use another network card(100 MB).
> I test locally and the speed is good, but just found it's very slow after
we
> moved the machined to the collocation. How to trouble this? Please help.
>
>
|||It affects things when you have more than two version on the
computer. If you use just SQLOLEDB, it will point to the
latest version of the provider. When you use SQLOLEDB.1, you
are specifying a specific version with the ProgID.
You may want to use the MDAC Component Checker to check your
MDAC installation. You can download it from:
http://msdn.microsoft.com/data/ref/mdac/downloads/
-Sue
On Wed, 18 Oct 2006 12:54:57 -0400, <js@.someone.com> wrote:
>just found out use name instead of ip and change from to SQLOLEDB
>provider=SQLOLEDB.1 and it works fine.
>why is that? please advice.
><js@.someone.com> wrote in message
>news:eyKXm6r8GHA.4708@.TK2MSFTNGP05.phx.gbl...
>they'
>we
>
Sunday, 25 March 2012
connect to sql
I have two machine one is application server (asp) and one is database
server (sql 2000).
Between them, I use a crossover cable connect each other(1GB) and also they'
re all connect to internet use another network card(100 MB).
I test locally and the speed is good, but just found it's very slow after we
moved the machined to the collocation. How to trouble this? Please help.just found out use name instead of ip and change from to SQLOLEDB
provider=SQLOLEDB.1 and it works fine.
why is that? please advice.
<js@.someone.com> wrote in message
news:eyKXm6r8GHA.4708@.TK2MSFTNGP05.phx.gbl...
> Hi
>
> I have two machine one is application server (asp) and one is database
> server (sql 2000).
> Between them, I use a crossover cable connect each other(1GB) and also
they'
> re all connect to internet use another network card(100 MB).
> I test locally and the speed is good, but just found it's very slow after
we
> moved the machined to the collocation. How to trouble this? Please help.
>
>|||It affects things when you have more than two version on the
computer. If you use just SQLOLEDB, it will point to the
latest version of the provider. When you use SQLOLEDB.1, you
are specifying a specific version with the ProgID.
You may want to use the MDAC Component Checker to check your
MDAC installation. You can download it from:
http://msdn.microsoft.com/data/ref/mdac/downloads/
-Sue
On Wed, 18 Oct 2006 12:54:57 -0400, <js@.someone.com> wrote:
>just found out use name instead of ip and change from to SQLOLEDB
>provider=SQLOLEDB.1 and it works fine.
>why is that? please advice.
><js@.someone.com> wrote in message
>news:eyKXm6r8GHA.4708@.TK2MSFTNGP05.phx.gbl...
>they'
>we
>
Tuesday, 20 March 2012
Connect to Analysis Services with specific username
Hello,
We are trying to develop an ASP .Net web application that connects to an SQL Server 2005 analysis services and executes MDX statements. We want the connection to be made using a specific user name that we specify in the code rather than having the web application inherit the logged on domain user account.
We tried to specifiy the user name in the connection string as follows, but it is still taking the logged in user account rather than the one specified.
Microsoft.AnalysisServices.Server s = new Microsoft.AnalysisServices.Server();
s.Connect("Provider=MSOLAP.3;Password=123;Persist Security Info=True;User ID=domain\username;Data Source=<server ip>;Initial Catalog=<analysis DB>");
Is this possible?
Note that if we are using the OLEDB 9.0 provider for Analysis Services to connect an excel sheet to the analysis database we can easily specify the user name and password, so is there a similar way to do the same from a .Net application?
Any feedback is appreciated, thanks,
Grace
If you want to use a Windows Indentity, then you can′t. For other connection options refer to the connection properties which are shown e.g. here:
http://www.ssas-info.com/ssas_articles/ssas_articles/analysis_services_2000_and_2005_connection_string_properties.html
Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||Thanks Jens,
The link helped a lot. We were able to connect using specific Roles and that is what we were looking for exactly but didn't know it exists.
Grace
Monday, 19 March 2012
Connect SQL database through ASP
to develop asp script to connect to the server database
(localhost). But I got invalid authorization error
message, any help will be greatly appreciated. Following
is my script:
<%Option Explicit%>
<html>
<head>
<title>Testing Connection1</title>
</head>
<body>
<%
Dim strConnectionString
strConnectionString = "Provider=SQLOLEDB.1;Data
Source=C:\Program Files\Microsoft SQL
Server\MSSQL\Data\Master.mdf"
Dim objConn, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open strConnectionString
strSQL = "SELECT First_Name, Last_Name FROM
Member_Master"
objRS.Open strSQL, objConn
Set objFirstName = objRS("First_Name")
Set objLastName = objRS("Last_Name")
Do Until objRS.EOF
Response.Write objFirstName & " " & objLastName
& "<BR>"
objRS.MoveNext
Loop
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
</body>
</html>
Thanks,
Sheridan
You have to set the DataSource in the connection string to the Server name,
not the operating system file name.
Dim strConnectionString
strConnectionString = "Provider=SQLOLEDB.1;Data Source=(local)"
Should work, although it is better to replace (local) with the actual name
of the SQL Server (which should be the same as your computername if you have
a default installation).
Jacco Schalkwijk
SQL Server MVP
"Sheridan" <anonymous@.discussions.microsoft.com> wrote in message
news:25c0b01c46111$a9a8d950$a401280a@.phx.gbl...
> I have SQL Server 2000 installed on my machine and tried
> to develop asp script to connect to the server database
> (localhost). But I got invalid authorization error
> message, any help will be greatly appreciated. Following
> is my script:
> <%Option Explicit%>
> <html>
> <head>
> <title>Testing Connection1</title>
> </head>
> <body>
> <%
> Dim strConnectionString
> strConnectionString = "Provider=SQLOLEDB.1;Data
> Source=C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\Master.mdf"
> Dim objConn, objRS
> Set objConn = Server.CreateObject("ADODB.Connection")
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objConn.Open strConnectionString
> strSQL = "SELECT First_Name, Last_Name FROM
> Member_Master"
> objRS.Open strSQL, objConn
> Set objFirstName = objRS("First_Name")
> Set objLastName = objRS("Last_Name")
> Do Until objRS.EOF
> Response.Write objFirstName & " " & objLastName
> & "<BR>"
> objRS.MoveNext
> Loop
> objRS.Close
> objConn.Close
> Set objRS = Nothing
> Set objConn = Nothing
> %>
> </body>
> </html>
> --
> Thanks,
> Sheridan
Connect SQL database through ASP
to develop asp script to connect to the server database
(localhost). But I got invalid authorization error
message, any help will be greatly appreciated. Following
is my script:
<%Option Explicit%>
<html>
<head>
<title>Testing Connection1</title>
</head>
<body>
<%
Dim strConnectionString
strConnectionString = "Provider=SQLOLEDB.1;Data
Source=C:\Program Files\Microsoft SQL
Server\MSSQL\Data\Master.mdf"
Dim objConn, objRS
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Open strConnectionString
strSQL = "SELECT First_Name, Last_Name FROM
Member_Master"
objRS.Open strSQL, objConn
Set objFirstName = objRS("First_Name")
Set objLastName = objRS("Last_Name")
Do Until objRS.EOF
Response.Write objFirstName & " " & objLastName
& "<BR>"
objRS.MoveNext
Loop
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
</body>
</html>
--
Thanks,
SheridanYou have to set the DataSource in the connection string to the Server name,
not the operating system file name.
Dim strConnectionString
strConnectionString = "Provider=SQLOLEDB.1;Data Source=(local)"
Should work, although it is better to replace (local) with the actual name
of the SQL Server (which should be the same as your computername if you have
a default installation).
Jacco Schalkwijk
SQL Server MVP
"Sheridan" <anonymous@.discussions.microsoft.com> wrote in message
news:25c0b01c46111$a9a8d950$a401280a@.phx
.gbl...
> I have SQL Server 2000 installed on my machine and tried
> to develop asp script to connect to the server database
> (localhost). But I got invalid authorization error
> message, any help will be greatly appreciated. Following
> is my script:
> <%Option Explicit%>
> <html>
> <head>
> <title>Testing Connection1</title>
> </head>
> <body>
> <%
> Dim strConnectionString
> strConnectionString = "Provider=SQLOLEDB.1;Data
> Source=C:\Program Files\Microsoft SQL
> Server\MSSQL\Data\Master.mdf"
> Dim objConn, objRS
> Set objConn = Server.CreateObject("ADODB.Connection")
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objConn.Open strConnectionString
> strSQL = "SELECT First_Name, Last_Name FROM
> Member_Master"
> objRS.Open strSQL, objConn
> Set objFirstName = objRS("First_Name")
> Set objLastName = objRS("Last_Name")
> Do Until objRS.EOF
> Response.Write objFirstName & " " & objLastName
> & "<BR>"
> objRS.MoveNext
> Loop
> objRS.Close
> objConn.Close
> Set objRS = Nothing
> Set objConn = Nothing
> %>
> </body>
> </html>
> --
> Thanks,
> Sheridan
Sunday, 11 March 2012
Connect From ASP to SQL Server Through ODBC
I'm a new comer to this APS language and hope sombody out there can help me with this
I'm trying to find codes for me to connect from ASP to Sql Server using ODBC.
Can anyone help me
ThanxOriginally posted by michaelfg81
Hi there,
I'm a new comer to this APS language and hope sombody out there can help me with this
I'm trying to find codes for me to connect from ASP to Sql Server using ODBC.
Can anyone help me
Thanx
Set db = Server.CreateObject("ADODB.Connection")
db.Open "Provider=SQLOLEDB; Data Source=SERVER; Initial Catalog=database; User ID=username; Password=password"
check this link :
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6442
regards,
Harshal.|||Dear Harshal,
Set db = Server.CreateObject("ADODB.Connection")
db.Open "Provider=SQLOLEDB; Data Source=SERVER; Initial Catalog=database; User ID=username; Password=password"
with this script above, isn't it connecting ASP to SQL Server via OLE DB?
Is connecting via OLE DB and ODBC which i have to set in the Administrator Tool for it to work, the same?
Thanx
Thursday, 8 March 2012
connect allowed from all except asp ?
a few serwers IIS 5.0 with asp pages
and one with SQL 2000 sp3
All of them running on Windows 2000 Adv Server sp4
And What I get:
Using Enterprise Manager, query analizer, VB application I can
connect to database with mixed creditenitals or with nt auth
(EntManager and Query analizer).
But when I'm trying from asp - it is not working at all
I have tried these connections strings
CF=" DSN=XXSQL;SERVER=XX;DATABASE=XXX;Network
=DBMSSOCN;Address=10.10.10.10,14
33;UID=XXuser;PWD=xxpass;"
CF="Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=xxuser;Initial Catalog=XXX;Data Source=XX"
CF="Provider=SQLOLEDB;Data Source=XX;Initial Catalog=XXX;Integrated
Security=SSPI"
CF= " dsn=xxsql;uid=xxuser;pwd=xxpass;database
=xxx;app=ASP;Connect
Timeout=60;Network Library=dbmssocn"
And nothing of them works.
I always get
"SQL Server does not exist or access denied"
Any idea what's wrong with connection?
Maybye with sql server something is not configured 'Did you add the IUSR_machine to the list of users that can log int to the
database in question?
Francisco
"ML" <maluleszek@.poczta.onet.pl> wrote in message
news:48fba10e.0407120244.102a5311@.posting.google.com...
> I have servers working with that combination
> a few serwers IIS 5.0 with asp pages
> and one with SQL 2000 sp3
> All of them running on Windows 2000 Adv Server sp4
> And What I get:
> Using Enterprise Manager, query analizer, VB application I can
> connect to database with mixed creditenitals or with nt auth
> (EntManager and Query analizer).
> But when I'm trying from asp - it is not working at all
> I have tried these connections strings
>
CF=" DSN=XXSQL;SERVER=XX;DATABASE=XXX;Network
=DBMSSOCN;Address=10.10.10.10,14
33;UID=XXuser;PWD=xxpass;"
> CF="Provider=SQLOLEDB.1;Persist Security Info=False;User
> ID=xxuser;Initial Catalog=XXX;Data Source=XX"
> CF="Provider=SQLOLEDB;Data Source=XX;Initial Catalog=XXX;Integrated
> Security=SSPI"
> CF= " dsn=xxsql;uid=xxuser;pwd=xxpass;database
=xxx;app=ASP;Connect
> Timeout=60;Network Library=dbmssocn"
> And nothing of them works.
> I always get
> "SQL Server does not exist or access denied"
> Any idea what's wrong with connection?
> Maybye with sql server something is not configured '|||Yes, this user was added, because this connection was working before.
And now I remove it and added it again.
But I found in logs that during weekend, when I lost ability to connect,
the power was goes down for a few second. (I have UPS)
It is possible to lost any login information because of that ?
(ups software or something ?)
"Francisco" <nomail@.baseball.net> wrote in message news:<OgdcL5QaEHA.596@.TK2MSFTNGP11.phx.gb
l>...[vbcol=seagreen]
> Did you add the IUSR_machine to the list of users that can log int to the
> database in question?
> Francisco
>
> "ML" <maluleszek@.poczta.onet.pl> wrote in message
> news:48fba10e.0407120244.102a5311@.posting.google.com...
> CF=" DSN=XXSQL;SERVER=XX;DATABASE=XXX;Network
=DBMSSOCN;Address=10.10.10.10,
14
> 33;UID=XXuser;PWD=xxpass;"
connect allowed from all except asp ?
a few serwers IIS 5.0 with asp pages
and one with SQL 2000 sp3
All of them running on Windows 2000 Adv Server sp4
And What I get:
Using Enterprise Manager, query analizer, VB application I can
connect to database with mixed creditenitals or with nt auth
(EntManager and Query analizer).
But when I'm trying from asp - it is not working at all
I have tried these connections strings
CF="DSN=XXSQL;SERVER=XX;DATABASE=XXX;Network=DBMSS OCN;Address=10.10.10.10,1433;UID=XXuser;PWD=xxpass ;"
CF="Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=xxuser;Initial Catalog=XXX;Data Source=XX"
CF="Provider=SQLOLEDB;Data Source=XX;Initial Catalog=XXX;Integrated
Security=SSPI"
CF= "dsn=xxsql;uid=xxuser;pwd=xxpass;database=xxx;app= ASP;Connect
Timeout=60;Network Library=dbmssocn"
And nothing of them works.
I always get
"SQL Server does not exist or access denied"
Any idea what's wrong with connection?
Maybye with sql server something is not configured ?
Did you add the IUSR_machine to the list of users that can log int to the
database in question?
Francisco
"ML" <maluleszek@.poczta.onet.pl> wrote in message
news:48fba10e.0407120244.102a5311@.posting.google.c om...
> I have servers working with that combination
> a few serwers IIS 5.0 with asp pages
> and one with SQL 2000 sp3
> All of them running on Windows 2000 Adv Server sp4
> And What I get:
> Using Enterprise Manager, query analizer, VB application I can
> connect to database with mixed creditenitals or with nt auth
> (EntManager and Query analizer).
> But when I'm trying from asp - it is not working at all
> I have tried these connections strings
>
CF="DSN=XXSQL;SERVER=XX;DATABASE=XXX;Network=DBMSS OCN;Address=10.10.10.10,14
33;UID=XXuser;PWD=xxpass;"
> CF="Provider=SQLOLEDB.1;Persist Security Info=False;User
> ID=xxuser;Initial Catalog=XXX;Data Source=XX"
> CF="Provider=SQLOLEDB;Data Source=XX;Initial Catalog=XXX;Integrated
> Security=SSPI"
> CF= "dsn=xxsql;uid=xxuser;pwd=xxpass;database=xxx;app= ASP;Connect
> Timeout=60;Network Library=dbmssocn"
> And nothing of them works.
> I always get
> "SQL Server does not exist or access denied"
> Any idea what's wrong with connection?
> Maybye with sql server something is not configured ?
|||Yes, this user was added, because this connection was working before.
And now I remove it and added it again.
But I found in logs that during weekend, when I lost ability to connect,
the power was goes down for a few second. (I have UPS)
It is possible to lost any login information because of that ?
(ups software or something ?)
"Francisco" <nomail@.baseball.net> wrote in message news:<OgdcL5QaEHA.596@.TK2MSFTNGP11.phx.gbl>...[vbcol=seagreen]
> Did you add the IUSR_machine to the list of users that can log int to the
> database in question?
> Francisco
>
> "ML" <maluleszek@.poczta.onet.pl> wrote in message
> news:48fba10e.0407120244.102a5311@.posting.google.c om...
> CF="DSN=XXSQL;SERVER=XX;DATABASE=XXX;Network=DBMSS OCN;Address=10.10.10.10,14
> 33;UID=XXuser;PWD=xxpass;"
Conn Obj
Hi All -
Prior to ASP .Net I use to create a connection object for SQL Server in my global.asa file and I would reference the obj whenever needed. how can I do the same in asp .net.
Here is my old asp sample:
Global.asa file:
Sub Session_OnStart
set session("conn") = createobject("adodb.connection")
session("conn").Open "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=xxx.xxx.xxx.xxx;DATABASE=xxxxx_db;UID=xx;PWD=xxxxxxxx;"
End Sub
Call from Other Pages:
sqlstr = "select * from members WHERE memberid = '" & session("mbr_memberno") & "'"
set objRS = session("conn").Execute(sqlstr)
... How can I do this in .net?
rich
You can do a similar thing in ASP.NET using the global.asax file.Though, I would caution against it: check out this article for somereasons why you want to avoid this:
http://www.codeproject.com/asp/dbobjects.asp
Jason
|||
So is it better to just set session variables for servername, uid and pass so if it changes its in one file rather than shifting through tons of code replacing sql server names. Also if I do create a session var of these items can I call them in the vb.net portion of the code?
rich
|||web.config is the place to do it...there's an article on my blog on how to do it..check it out.|||The proper way to do it is to store the connection string itself in theweb.config (as the previous post suggests -- though others say thatstoring usernames and passwords in an unecrypted format is a bad idea-- trusted connections are better they say) and instantiate theconnection object and close the connection object on each page.Jason
|||
You can encrypt the connection string and put it in the web config. There's a good example of doing so here:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT08.asp
Friday, 24 February 2012
Conflicting docs on how to render
I am trying to use the render method to render to a byte array in an ASP.Net application and I am having a problem in that there is a lot of conflicting information in the books and the docs on how to do this. The latest docs I read led to the following code...
ReportingService2005 _rs = new ReportingService2005();
//have to use custom credentials because ASPNET does not have sufficient authority...
NetworkCredential myCred = new NetworkCredential("myuserid", "mypassword", "mydomain");
CredentialCache myCash = new CredentialCache();
myCash.Add(new Uri("http://localhost/myWebSiteName"), "NTLM", myCred);
_rs.Credentials = myCash;
_rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
//we just have one parameter...
ParameterValue[] Parameters = new ParameterValue[1];
Parameters[0].Name = "myReportID";
Parameters[0].Value = argmyReportID;
//Render the report to a byte array...
byte[] data;
data = _rs. oops there is no Render method!!
The first docs I read (WROX BOOK on SSRS2005) said to use the ReportingService class but there is no such class. I then found docs saying to use ReportingService2005 class as I did above. But that class has no Render method. Today I found other docs that say to use ReportExecutionService class.
Why are there so many conflicting docs. What class am I supposed to use to do a render?
Thanks,
Gary
ReportServices.ReportingService rs = new ReportServices.ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
byte[] ResultStream; // bytearray for result stream
string[] StreamIdentifiers; // string array for stream idenfiers
string OptionalParam = null; // string out param for optional parameters
ReportServices.ParameterValue[] optionalParams = null; // parametervalue array for optional parameters
ReportServices.Warning[] optionalWarnings = null; // warning array for optional warnings
ResultStream = rs.Render("/ReportProject1/Report1", "HTML4.0", null,
"<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>", null, null,
null, out OptionalParam, out OptionalParam, out optionalParams,
out optionalWarnings, out StreamIdentifiers);
After creating a webServices proxy class on ReportService.asmx.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
|||I get an error on
ResultStream = rs.Render(My.Settings.ReportPath, "PDF", Nothing, "<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>", Nothing, Nothing, _
Nothing, OptionalParam, OptionalParam, optionalParams, _
optionalWarnings, StreamIdentifiers)
it says that "render" is not a member of reportService. any ideas?
|||Which WebService (*.asmx) did you reference ?
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
I am using both the reportExecution and ReportService. After struggling with it for a while I went and looked at the renderand save sample that someone had pointed out earlier. This time the code actually worked with some minor modifications. I am posting the whole code routine below in case someone has the same issue in the future.
Public Sub ExportToDisk()
Dim strFileName As String = System.Windows.Forms.Application.StartupPath
Dim strAppPath As String = System.Windows.Forms.Application.StartupPath
Try
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.EmailInvoices_ReportExecution_ReportExecutionService
Dim result As Byte() = Nothing
Dim reportPath As String = My.Settings.ReportPath
Dim format As String = "PDF"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
Dim parameters(0) As ReportExecution.ParameterValue
parameters(0) = New ReportExecution.ParameterValue()
parameters(0).Name = "InvoiceNumber"
parameters(0).Value = Me.Invoice
Dim credentials As ReportExecution.DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As ReportExecution.Warning() = Nothing
Dim reportHistoryParameters As ReportExecution.ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
SessionId = rs.ExecutionHeaderValue.ExecutionID
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)
Try
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch e As System.Exception
Console.WriteLine(e.ToString)
End Try
' Try
Using stream As FileStream = File.OpenWrite(strFileName & "\EmailFiles\" & Me.Invoice & ".PDF")
stream.Write(result, 0, result.Length)
stream.Close()
stream.Dispose()
End Using
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
End Sub
|||I am using both the reportExecution and ReportService. After struggling with it for a while I went and looked at the renderand save sample that someone had pointed out earlier. This time the code actually worked with some minor modifications. I am posting the whole code routine below in case someone has the same issue in the future.
Public Sub ExportToDisk()
Dim strFileName As String = System.Windows.Forms.Application.StartupPath
Dim strAppPath As String = System.Windows.Forms.Application.StartupPath
Try
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.EmailInvoices_ReportExecution_ReportExecutionService
Dim result As Byte() = Nothing
Dim reportPath As String = My.Settings.ReportPath
Dim format As String = "PDF"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
Dim parameters(0) As ReportExecution.ParameterValue
parameters(0) = New ReportExecution.ParameterValue()
parameters(0).Name = "InvoiceNumber"
parameters(0).Value = Me.Invoice
Dim credentials As ReportExecution.DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As ReportExecution.Warning() = Nothing
Dim reportHistoryParameters As ReportExecution.ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
SessionId = rs.ExecutionHeaderValue.ExecutionID
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)
Try
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch e As System.Exception
Console.WriteLine(e.ToString)
End Try
' Try
Using stream As FileStream = File.OpenWrite(strFileName & "\EmailFiles\" & Me.Invoice & ".PDF")
stream.Write(result, 0, result.Length)
stream.Close()
stream.Dispose()
End Using
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
End Sub
|||I am using both the reportExecution and ReportService. After struggling with it for a while I went and looked at the renderand save sample that someone had pointed out earlier. This time the code actually worked with some minor modifications. I am posting the whole code routine below in case someone has the same issue in the future.
Public Sub ExportToDisk()
Dim strFileName As String = System.Windows.Forms.Application.StartupPath
Dim strAppPath As String = System.Windows.Forms.Application.StartupPath
Try
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.EmailInvoices_ReportExecution_ReportExecutionService
Dim result As Byte() = Nothing
Dim reportPath As String = My.Settings.ReportPath
Dim format As String = "PDF"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
Dim parameters(0) As ReportExecution.ParameterValue
parameters(0) = New ReportExecution.ParameterValue()
parameters(0).Name = "InvoiceNumber"
parameters(0).Value = Me.Invoice
Dim credentials As ReportExecution.DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As ReportExecution.Warning() = Nothing
Dim reportHistoryParameters As ReportExecution.ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
SessionId = rs.ExecutionHeaderValue.ExecutionID
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)
Try
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch e As System.Exception
Console.WriteLine(e.ToString)
End Try
' Try
Using stream As FileStream = File.OpenWrite(strFileName & "\EmailFiles\" & Me.Invoice & ".PDF")
stream.Write(result, 0, result.Length)
stream.Close()
stream.Dispose()
End Using
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
End Sub
Conflicting docs on how to render
I am trying to use the render method to render to a byte array in an ASP.Net application and I am having a problem in that there is a lot of conflicting information in the books and the docs on how to do this. The latest docs I read led to the following code...
ReportingService2005 _rs = new ReportingService2005();
//have to use custom credentials because ASPNET does not have sufficient authority...
NetworkCredential myCred = new NetworkCredential("myuserid", "mypassword", "mydomain");
CredentialCache myCash = new CredentialCache();
myCash.Add(new Uri("http://localhost/myWebSiteName"), "NTLM", myCred);
_rs.Credentials = myCash;
_rs.Url = "http://localhost/ReportServer/ReportService2005.asmx";
//we just have one parameter...
ParameterValue[] Parameters = new ParameterValue[1];
Parameters[0].Name = "myReportID";
Parameters[0].Value = argmyReportID;
//Render the report to a byte array...
byte[] data;
data = _rs. oops there is no Render method!!
The first docs I read (WROX BOOK on SSRS2005) said to use the ReportingService class but there is no such class. I then found docs saying to use ReportingService2005 class as I did above. But that class has no Render method. Today I found other docs that say to use ReportExecutionService class.
Why are there so many conflicting docs. What class am I supposed to use to do a render?
Thanks,
Gary
ReportServices.ReportingService rs = new ReportServices.ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
byte[] ResultStream; // bytearray for result stream
string[] StreamIdentifiers; // string array for stream idenfiers
string OptionalParam = null; // string out param for optional parameters
ReportServices.ParameterValue[] optionalParams = null; // parametervalue array for optional parameters
ReportServices.Warning[] optionalWarnings = null; // warning array for optional warnings
ResultStream = rs.Render("/ReportProject1/Report1", "HTML4.0", null,
"<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>", null, null,
null, out OptionalParam, out OptionalParam, out optionalParams,
out optionalWarnings, out StreamIdentifiers);
After creating a webServices proxy class on ReportService.asmx.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
|||I get an error on
ResultStream = rs.Render(My.Settings.ReportPath, "PDF", Nothing, "<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>", Nothing, Nothing, _
Nothing, OptionalParam, OptionalParam, optionalParams, _
optionalWarnings, StreamIdentifiers)
it says that "render" is not a member of reportService. any ideas?
|||Which WebService (*.asmx) did you reference ?
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
I am using both the reportExecution and ReportService. After struggling with it for a while I went and looked at the renderand save sample that someone had pointed out earlier. This time the code actually worked with some minor modifications. I am posting the whole code routine below in case someone has the same issue in the future.
Public Sub ExportToDisk()
Dim strFileName As String = System.Windows.Forms.Application.StartupPath
Dim strAppPath As String = System.Windows.Forms.Application.StartupPath
Try
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.EmailInvoices_ReportExecution_ReportExecutionService
Dim result As Byte() = Nothing
Dim reportPath As String = My.Settings.ReportPath
Dim format As String = "PDF"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
Dim parameters(0) As ReportExecution.ParameterValue
parameters(0) = New ReportExecution.ParameterValue()
parameters(0).Name = "InvoiceNumber"
parameters(0).Value = Me.Invoice
Dim credentials As ReportExecution.DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As ReportExecution.Warning() = Nothing
Dim reportHistoryParameters As ReportExecution.ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
SessionId = rs.ExecutionHeaderValue.ExecutionID
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)
Try
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch e As System.Exception
Console.WriteLine(e.ToString)
End Try
' Try
Using stream As FileStream = File.OpenWrite(strFileName & "\EmailFiles\" & Me.Invoice & ".PDF")
stream.Write(result, 0, result.Length)
stream.Close()
stream.Dispose()
End Using
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
End Sub
|||I am using both the reportExecution and ReportService. After struggling with it for a while I went and looked at the renderand save sample that someone had pointed out earlier. This time the code actually worked with some minor modifications. I am posting the whole code routine below in case someone has the same issue in the future.
Public Sub ExportToDisk()
Dim strFileName As String = System.Windows.Forms.Application.StartupPath
Dim strAppPath As String = System.Windows.Forms.Application.StartupPath
Try
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.EmailInvoices_ReportExecution_ReportExecutionService
Dim result As Byte() = Nothing
Dim reportPath As String = My.Settings.ReportPath
Dim format As String = "PDF"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
Dim parameters(0) As ReportExecution.ParameterValue
parameters(0) = New ReportExecution.ParameterValue()
parameters(0).Name = "InvoiceNumber"
parameters(0).Value = Me.Invoice
Dim credentials As ReportExecution.DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As ReportExecution.Warning() = Nothing
Dim reportHistoryParameters As ReportExecution.ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
SessionId = rs.ExecutionHeaderValue.ExecutionID
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)
Try
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch e As System.Exception
Console.WriteLine(e.ToString)
End Try
' Try
Using stream As FileStream = File.OpenWrite(strFileName & "\EmailFiles\" & Me.Invoice & ".PDF")
stream.Write(result, 0, result.Length)
stream.Close()
stream.Dispose()
End Using
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
End Sub
|||I am using both the reportExecution and ReportService. After struggling with it for a while I went and looked at the renderand save sample that someone had pointed out earlier. This time the code actually worked with some minor modifications. I am posting the whole code routine below in case someone has the same issue in the future.
Public Sub ExportToDisk()
Dim strFileName As String = System.Windows.Forms.Application.StartupPath
Dim strAppPath As String = System.Windows.Forms.Application.StartupPath
Try
Dim rs As New ReportExecutionService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.EmailInvoices_ReportExecution_ReportExecutionService
Dim result As Byte() = Nothing
Dim reportPath As String = My.Settings.ReportPath
Dim format As String = "PDF"
Dim historyID As String = Nothing
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
' Prepare report parameter.
Dim parameters(0) As ReportExecution.ParameterValue
parameters(0) = New ReportExecution.ParameterValue()
parameters(0).Name = "InvoiceNumber"
parameters(0).Value = Me.Invoice
Dim credentials As ReportExecution.DataSourceCredentials() = Nothing
Dim showHideToggle As String = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As ReportExecution.Warning() = Nothing
Dim reportHistoryParameters As ReportExecution.ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim execInfo As New ExecutionInfo
Dim execHeader As New ExecutionHeader()
Dim SessionId As String
Dim extension As String = ""
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
rs.SetExecutionParameters(parameters, "en-us")
SessionId = rs.ExecutionHeaderValue.ExecutionID
Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)
Try
result = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)
execInfo = rs.GetExecutionInfo()
Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)
Catch e As System.Exception
Console.WriteLine(e.ToString)
End Try
' Try
Using stream As FileStream = File.OpenWrite(strFileName & "\EmailFiles\" & Me.Invoice & ".PDF")
stream.Write(result, 0, result.Length)
stream.Close()
stream.Dispose()
End Using
Catch e As Exception
Console.WriteLine(e.Message)
End Try
Catch e As System.Exception
MessageBox.Show(e.Message)
End Try
End Sub
Friday, 10 February 2012
Configure SQL Server 2005 to allow remote connections!
Hello there,
I just deployed a new ASP.NET 2.0 website on a remote serverhttp://www.alrazem.com/. and when i want to log on, or when any connection to the database happens!! the following error ocurs.
Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
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.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Anyways, I searched the new. and i found this link:http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277... I followed the instructions and changed theSurface Area Configuration for Services and Connectionsto Local and remote connections.and Applied both protocols. Then redeployed the application. but the error still ocurs.
I didn't restart my machine after changing the SQL to remote. but i did the website from scratch again. and created a new connectionstring and database!!!
Any help? Thanks!
Hi singlenipple,
It seems that the after enabling the remote connection, you still cannot connect to it.
In this case I suggest you try the following steps.
1. Restart the computer and make sure that your SQL Server service is started.
2. Check if there is any firewall app running on this machine that prevents your service from being accessed.
3. Create a .txt file on a remote client machine, rename it to .udl, and double click on it. You will see a connection property dialog then. You can use this wizard to test the connection.