Send Data To A Network Printer From A CLR Trigger
Aug 24, 2006Hi,
Does anyone know how to print from a CLR trigger?
Cheers
James
Hi,
Does anyone know how to print from a CLR trigger?
Cheers
James
Hi,
in our environment
- Windows XP
- SQL Server Express 2005
- Internet connection via TCP/IP protocol
The described network error occurs, when we unplug the network cable:
[DBNETLIB][ConnectionWrite (send()).] General network error.
The affected database resides on the locally installed SQLExpress, it doesn't use any network connections. The error doesn't occur immediately, in most cases there are up to 30 seconds where data can be (correctly!) written to the recordset, but after that timeout the connetion is broken.
We already tried out the described workarounds:
- disable named pipes protocol
- set SynAttackProtect=0 in HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters
The error doesn't occur with MSDE (SQL 2000) or under Vista.
Thanks for help!
Mathias
We just replaced an older Windows 2000 sp4 server with a new Window 2003 Standard Edition sp2 server to run our batch processing. We noticed that when the SQL command times out we now get the following error in the ADO command object error collection.
[DBNETLIB][ConnectionWrite (send()).] General network error. Check you network documentation.
Native Error: 11
SQL State: HY018
msado15.dll version 2.82.3959 is on this server.
On other servers running Windows 2003 Enterprise Edition sp1 the error on the ADO command object is normal with.
Timeout expired
Native Error: 0
SQL State: HYT00
msado15.dll version 2.82.1830 is on this server.
The SQL server they are talking to is on the other side of a firewall. It is SQL 2005 sp2 running on Windows 2000 sp4.
I have also tested this on a Windows 2003 sp2 server that doesn't have to cross a firewall and get the correct Timeout error. It also has the same version of msado15.dll as problem server.
The application is a collection of VB6 Components that are running in COM+ applications. I have isolated the test application to our one SQL interface component and have build a test vbs that can reproduce this on demand. The VB6 Components were not modified in any way for this change and have been working fine for many years prior to this.
All other aspects of our batch processing works as expected. Transactions are working fine. As long as the SQL doesn't timeout everything is normal. DTCPing was used to ensure both servers have correct ports open to allow DTC traffic. Checked the SynAttackProtect setting on SQL and this is not an issue since other clients have no problems.
One point I would like to add is that this new server was initially setup with a temporary server name and then was changed to use the name of the original server on move day. Don't know if this has any impact or not.
Hi,
I am using Trigger to send me a mail, when ever any DML operation occur on my DepartmentMaster table. my trigger is as follow. CREATE TRIGGER reminder
ON DepartmentMaster
FOR INSERT, UPDATE, DELETE
AS
EXEC master..xp_sendmail 'MaryM',
'Don''t forget to print a report for the distributors.'delete from DepartmentMaster where deptcode = '02'
my out express is configured with default account. but when ever i delete any row from DepartmentMaster table mail is not sent and i get following error..
Server: Msg 18030, Level 16, State 1, Line 0xp_sendmail: Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client.
I have a basic trigger that populated an audit table, but I want to add logic to that to send an email everytime the trigger is called,Is there a easy way to add code to my basic trigger to send an email to me everytime the data changes.Thanks
View 1 Replies View RelatedHello,
I'm tryng to set up a CLR Trigger, when executing i get this error:
Msg 6522, Niveau 16, État 1, Procédure Trigger_EnvoiEmail, Ligne 1
Une erreur .NET Framework s'est produite au cours de l'exécution de la routine ou de la fonction d'agrégation définie par l'utilisateur 'Trigger_EnvoiEmail' :
System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
System.Security.SecurityException:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.Mail.SmtpClient.Initialize()
at System.Net.Mail.SmtpClient..ctor(String host)
at AffYEmailQueue.MailHelper.SendMailMessage(String from, String destinataire, String bcc, String cc, String subject, String Htmlbody, String Textbody, Int32 idAFFY)
at AffYEmailQueue.Triggers.EnvoiEmail()
Can anybody help me ? thanks
Hi,
I have an c# windows service, which is running on the same machine where my mssql server is installed. This service must be informed for each insert/update/delete event on one specific table.
My idea was to create an CLR Trigger for this table which can communicate with this service via .NET remoting. But the problem is, that the system.runtime.remoting assembly is not integrated within the mssql clr enviroment => i can't use remoting.
Are there any other idea's how can i solve this?
Best regards,
Thomas
Anybody please help me about the printer. I have a user want to print the letter from tray3, he slects the tray3, but it always print from tray2. I tried by myself. It is the same thing. Anybody can help me?
View 9 Replies View RelatedHi Dear All!
I am Crystal Reports Developer and I am new in SSIS environment. I have started to read Professional SQL Server 2005 IS book. I am really confused by many tasks to choose.
I need to develop reports from data warehouse. But before I have to send the data from operational database (SQL Server 2000) to warehouse (SQL Server 2005) monthly - I have a script for retrieving the data. For my package, I chose Data Flow Task, Execute SQL Task, and OLE DB Destination, and it does not work.
Please help me if I can look similar packages performing?
Thank you!!
Greetings,
1. I would like to print one of my database to a printer, how can I do that?
2. I would like to transfer one of my database to Microsoft Excel 97/2000, how can I do that?
Thank you very much.
Is there a way to route a file directly to a printer? I have a process that creates PDF file in a known location and I would like to route them directly to the printer after creation.
View 2 Replies View RelatedI have a client who tells me in Access you could assign the printer directly to the report using PrtDevNames and PrtDevMode. Apparently it's true.
Can this be done in Reporting Services?
Is there anyway to count number of pages sent to the printer, to track them?
View 2 Replies View RelatedI am trying to modify the Printer Delivery Sample (RS 2005).
The original sample works fine: there was no any problem with deployment and running it.
What I need to accomplish is saving each delivered report as a local XML file.
For now (to start with), I'm just trying to read the rendered report as XML, and write the string (whatever the report contains) into a text file.
I added the following code to the PrintReport(...) method in the PrinterDeliveryProvider.cs file:
deviceInfo = String.Format(
System.Globalization.CultureInfo.InvariantCulture,
@"<DeviceInfo><OutputFormat>{0}</OutputFormat></DeviceInfo>",
"xml");
RenderedOutputFile[] testFiles = notification.Report.Render("XML", deviceInfo);
using (FileStream fs = File.Create(@"C: est est.txt"))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("******************");
try
{
Stream streamTemp = (Stream)testFiles[0].Data;
byte [] byteData = new byte[streamTemp.Length];
for (int i = 0; i < byteData.Length; i++)
{
byteData[ i ] = (byte)streamTemp.ReadByte();
}
using (MemoryStream ms = new MemoryStream(byteData))
{
string result = Convert.ToBase64String(ms.ToArray());
sw.WriteLine(result);
}
}
catch (Exception ex)
{
sw.WriteLine(ex.Message);
}
sw.Flush();
}
}
After I re-deploy the modified assembly and create a simple subscription, it fires, and there are no exceptions. But instead of some good-looking XML in the test.txt file, I get this:
******************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
[Actually, there are much more slashes, but I am showing just the beginning of the file - for brevity...]
When I run this report in ReportManager and export it as "XML file with report data", that XML exported file looks exactly as I expect it to. So, the data is there, in the report, but how do I extract it?
I've been trying to figure out why I am not getting the real content of the report in XML format.
Maybe, this line is wrong: RenderedOutputFile[] testFiles = notification.Report.Render("XML", deviceInfo);
AND/OR this line is wrong: deviceInfo = String.Format(................etc.
AND/OR I am using a wrong method for converting the Stream to a string.
...or, something else?
Could someone kindly help me figure out what I'm doing wrong, please?
I have a windows NT service, which prints to a laser printer programmatically using MSRS 2K. It works fine with a HP printer however when I try printing to a Lexmark Printer it does not always print. Somebody help. Microsoft please release a latest patch for MSRS 2K, its been so long since we had one.
View 2 Replies View RelatedThe code below is a class file done in vb.net. The original idea came from reading this forum and some blogs.
To use the code below, you can create a windows application or service.
then create a class file and drop this code in it.
Remeber to reference the 2005 report execution service and also in the program settings include the path to your server.
IE: ReportExecutionService = http://localhost/ReportServer/ReportExecution2005.asmx or whatever your server URL is at.
Setup the public properties for printername (sharenames work fine), Number of copies and Report name.
That is all there is to it. This code is REALLY expandable to add more options.
Please remember to let me kow if you like this.
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Printing
Imports System.IO
Imports System.Web.Services.Protocols
Imports PrintReport.ReportExecution
Imports System.Runtime.InteropServices ' For Marshal.Copy
Namespace PrintReport
Friend Class app
Private m_sPrinterName As String
Private m_sReportName As String
Private m_sNumCopies As Integer
<STAThread()> _
Public Sub Main(ByVal args As String())
Dim pe As PrintMain = New PrintMain()
pe.PrintReport(m_sPrinterName, m_sReportName, m_sNumCopies)
End Sub
Public Property pPrinterName()
Get
Return m_sPrinterName
End Get
Set(ByVal value)
m_sPrinterName = value
End Set
End Property
Public Property pReportName()
Get
Return m_sReportName
End Get
Set(ByVal value)
m_sReportName = value
End Set
End Property
Public Property pNumCopies()
Get
Return m_sNumCopies
End Get
Set(ByVal value)
m_sNumCopies = value
End Set
End Property
End Class
Friend Class PrintMain
Private rs As New ReportExecutionService()
Private m_renderedReport As Byte()()
Private m_delegate As Graphics.EnumerateMetafileProc = Nothing
Private m_currentPageStream As MemoryStream
Private m_metafile As Metafile = Nothing
Private m_numberOfPages As Integer
Private m_currentPrintingPage As Integer
Private m_lastPrintingPage As Integer
Public Sub New()
' Create proxy object and authenticate
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = My.Settings.ReportExecutionService '"http://localhost/ReportServer/ReportExecution2005.asmx"
End Sub
Public Function RenderReport(ByVal reportPath As String) As Byte()()
' Private variables for rendering
Dim deviceInfo As String
Dim format As String = "IMAGE"
Dim firstPage As Byte() = Nothing
Dim encoding As String = ""
Dim mimeType As String = ""
Dim warnings As Warning() = Nothing
Dim reportHistoryParameters As ParameterValue() = Nothing
Dim streamIDs As String() = Nothing
Dim pages As Byte()() = Nothing
Dim historyID As String = Nothing
Dim showHideToggle 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
' Build device info based on the start page
deviceInfo = String.Format("<DeviceInfo><OutputFormat>{0}</OutputFormat></DeviceInfo>", "emf")
'Exectute the report and get page count.
Try
' Renders the first page of the report and returns streamIDs for
' subsequent pages
firstPage = rs.Render(format, deviceInfo, extension, encoding, mimeType, warnings, streamIDs)
' The total number of pages of the report is 1 + the streamIDs
m_numberOfPages = streamIDs.Length + 1
pages = New Byte(m_numberOfPages - 1)() {}
' The first page was already rendered
pages(0) = firstPage
Dim pageIndex As Integer = 1
Do While pageIndex < m_numberOfPages
' Build device info based on start page
deviceInfo = String.Format("<DeviceInfo><OutputFormat>{0}</OutputFormat><StartPage>{1}</StartPage></DeviceInfo>", "emf", pageIndex + 1)
pages(pageIndex) = rs.Render(format, deviceInfo, extension, encoding, mimeType, warnings, streamIDs)
pageIndex += 1
Loop
Catch ex As SoapException
'Console.WriteLine(ex.Detail.InnerXml)
Catch ex As Exception
'Console.WriteLine(ex.Message)
Finally
'Console.WriteLine("Number of pages: {0}", pages.Length)
End Try
Return pages
End Function
Public Function PrintReport(ByVal printerName As String, ByVal ReportName As String, Optional ByVal NumCopies As Integer = 0) As Boolean
Me.RenderedReport = Me.RenderReport(ReportName)
Try
' Wait for the report to completely render.
If m_numberOfPages < 1 Then
Return False
End If
Dim printerSettings As PrinterSettings = New PrinterSettings()
printerSettings.MaximumPage = m_numberOfPages
printerSettings.MinimumPage = 1
printerSettings.PrintRange = PrintRange.SomePages
printerSettings.FromPage = 1
printerSettings.ToPage = m_numberOfPages
printerSettings.Copies = NumCopies
printerSettings.PrinterName = printerName
Dim pd As PrintDocument = New PrintDocument()
m_currentPrintingPage = 1
m_lastPrintingPage = m_numberOfPages
pd.PrinterSettings = printerSettings
' Print report
'Console.WriteLine("Printing report...")
AddHandler pd.PrintPage, AddressOf pd_PrintPage
pd.Print()
Catch ex As Exception
'Console.WriteLine(ex.Message)
Finally
' Clean up goes here.
End Try
Return True
End Function
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
ev.HasMorePages = False
If m_currentPrintingPage <= m_lastPrintingPage AndAlso MoveToPage(m_currentPrintingPage) Then
' Draw the page
ReportDrawPage(ev.Graphics)
' If the next page is less than or equal to the last page,
' print another page.
If m_currentPrintingPage <= m_lastPrintingPage Then
m_currentPrintingPage += 1
ev.HasMorePages = True
End If
End If
End Sub
' Method to draw the current emf memory stream
Private Sub ReportDrawPage(ByVal g As Graphics)
If Nothing Is m_currentPageStream OrElse 0 = m_currentPageStream.Length OrElse Nothing Is m_metafile Then
Return
End If
SyncLock Me
' Set the metafile delegate.
Dim width As Integer = m_metafile.Width
Dim height As Integer = m_metafile.Height
m_delegate = New Graphics.EnumerateMetafileProc(AddressOf MetafileCallback)
' Draw in the rectangle
Dim destPoint As Point = New Point(0, 0)
g.EnumerateMetafile(m_metafile, destPoint, m_delegate)
' Clean up
m_delegate = Nothing
End SyncLock
End Sub
Private Function MoveToPage(ByVal page As Int32) As Boolean
' Check to make sure that the current page exists in
' the array list
If Nothing Is Me.RenderedReport(m_currentPrintingPage - 1) Then
Return False
End If
' Set current page stream equal to the rendered page
m_currentPageStream = New MemoryStream(Me.RenderedReport(m_currentPrintingPage - 1))
' Set its postion to start.
m_currentPageStream.Position = 0
' Initialize the metafile
If Not Nothing Is m_metafile Then
m_metafile.Dispose()
m_metafile = Nothing
End If
' Load the metafile image for this page
m_metafile = New Metafile(CType(m_currentPageStream, Stream))
Return True
End Function
Private Function MetafileCallback(ByVal recordType As EmfPlusRecordType, ByVal flags As Integer, ByVal dataSize As Integer, ByVal data As IntPtr, ByVal callbackData As PlayRecordCallback) As Boolean
Dim dataArray As Byte() = Nothing
' Dance around unmanaged code.
If data <> IntPtr.Zero Then
' Copy the unmanaged record to a managed byte buffer
' that can be used by PlayRecord.
dataArray = New Byte(dataSize - 1) {}
Marshal.Copy(data, dataArray, 0, dataSize)
End If
' play the record.
m_metafile.PlayRecord(recordType, flags, dataSize, dataArray)
Return True
End Function
Public Property RenderedReport() As Byte()()
Get
Return m_renderedReport
End Get
Set(ByVal value As Byte()())
m_renderedReport = value
End Set
End Property
End Class
end namespace
I am looking for a way to remove the printer symbol from the report manger because it dows not work on some client machines because they are locked down. For us it is completely sufficient to export to PDF.
Is there a setting or an entry in the web config or something else. A hint would be helpful
Thanks
HANNES
I have installed the printer delivery sample and made the changes to the config files as described in the documentation but can only see it available as an option in the data driven subscriptions section. Anyone know how I can get it to show up in the standard subscriptions option?
Cheers,
Martin
I believe this is an extension of the problem described here:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115351
The service pack for Visual Studio has fixed the problem when I print my report from VS, however when I deploy and print my reports from the SSRS website they are still incorrect.
My SSRS server is running SQL 2005 with service pack 2 installed and the 9.00.3152 9333097 Cumulative hotfix package (build 3152) for SQL Server 2005 Service Pack 2 also applied.
I find it hard to believe the problem was fixed in the developer tool but NOT in the client tool?
How can I develop reports when the output from the developer tool is different to the output from the client tool?
For example I specify a box to be 5cm wide, and when printed from visual studio it is 5cm wide, but when printed from the SSRS website it is not 5cm wide!
Thanks.
Hello,
I am trying to get a SSRS 2005 report to print from my Visual Studio 2005 C++ application without using the ReportViewer to preview it first. What I have done is created a dll that I call into when I want to access a certain report and print it. While searching around on the internet I found an MSDN article about printing a report without previewing and it had an example in C# code. So I used that as a guide for my C++ code but I am still having problems with rendering the report properly so it can be printed. When I try to render a report using the "Image" format, my streamid string is empty but the byte array that the render routine returns is not. Here is the code I am using, what could be the problem here?
Note: m_Streams is define elsewhere as
array<String^>^ m_Streams = gcnew array<String^>(10);
void Print::Export(LocalReport^ report)
{
array<Warning^>^ Warn = gcnew array<Warning^>(10);
String^ deviceinfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.25in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>0.25in</MarginBottom>" +
"</DeviceInfo>";
String^ mimeType;
String^ enc;
String^ FileExt;
array<Byte>^ bytes;
bytes = report->Render("Image",deviceinfo, mimeType, enc, FileExt, m_Streams,Warn); // m_Streams has a length of
return; // 0 after the Render
}
void Print:: PrintPage(System:: Object^ sender, System:: Drawing:: Printing:: PrintPageEventArgs^ ev)
{
Metafile^ pageImage = gcnew Metafile(m_Streams[m_CurrentPage]);
ev->Graphics->DrawImage(pageImage, ev->PageBounds);
m_CurrentPage++;
ev->HasMorePages = (m_CurrentPage < m_Streams->Length);
return;
}
void Print:rintRpt()
{
String^ printerName = "Default";
if (m_Streams->Length < 0)
return;
PrintDocument^ printDoc = gcnew PrintDocument();
if (!printDoc->PrinterSettings->IsValid) {
return;
}
printDoc->PrintPage += gcnew PrintPageEventHandler(this, &Print:: PrintPage);
printDoc->Print();
return;
}
void Print::Run()
{
LocalReport^ report = gcnew LocalReport();
DataSet^ ds = gcnew DataSet();
LoadData(ds);
report->ReportPath = "c:\bmi\bulrpt\Report1.rdlc";
ReportDataSource^ RDS = gcnew ReportDataSource();
RDS->Name = "DataSet1_Subject";
RDS->Value = ds->Tables["Subject"];
report->DataSources->Add(RDS);
Export(report);
PrintRpt();
return;
}
DataTable^ Print:: LoadData(DataSet^ ds)
{
System:: String ^ConnStr = "SELECT * FROM Subject";
SqlConnection^ conn = gcnew SqlConnection("Data Source=JOE-PC\BMIMSDESERVER; Initial Catalog=stx52013;Integrated Security = TRUE");
SqlCommand^ command = gcnew SqlCommand(ConnStr, conn);
SqlDataAdapter^ adapt = gcnew SqlDataAdapter(command);
adapt->TableMappings->Add("Table", "Subject");
conn->Open();
adapt->Fill(ds);
return ds->Tables["Subject"];
}
Very strange problem here with Reporting Services SQL 2005 SP1 with latest patch KB 918222 on Windows Server 2003 SP1. The clients PC are Windows XP both SP1 and SP2 and that's not affecting our problems.
When my default printer is set to the "Printer 1" (HP LaserJet 9000), when i look a report's into the Report Viewer and i click on the print button (printer image button that use the ActiveX RSClientPrint), i let the default printer to "Printer 1". In this case, the report is printed correctly.
Again with my default printer set to "Printer 1", i look the same report into the Report Viewer and i click on the print button again. This time i select another printer "Printer 2" (an older HP LaserJet 8000 DN) and the report is printed correctly.
Now the problem is when i set the "Printer 2" as default printer. If i go to the Report Viewer and i click on the print button for the same report that was printed correctly before, now the report seem's to be ok into the preview before i print, but when i send the job to the "Printer 2" the report require a unknown paper format, so the "Printer 2" ask paper into the tray 1 (manual feed) and the result of the printed report is not good. The right and the bottom seem's to be cutted. I tried to reduce the report dimension without good results. The report is always cutted to right and bottom and the printer ask paper into the tray 1 (unknown paper).
Is't not the end, if i print the same report on the "Printer 1" when the default printer is "Printer 2", the report is printed correctly.
I have tried to use another printer than the "Printer 2" to see if the problem is the printer. I tried the "Printer 3" (HP LaserJet 9050) as default printer, i print the report on this one and i have the same problem than with the "Printer 2". And if i set "Printer 1" as default and i print on the "Printer 3" the report is printing correctly.
For all the printers i have the latest drivers. The same problem is occuring on all other PC other than mine.
We have checked the printers configuration and all seem's to have the same configuration.
Can this be a bug with the ActiveX RSClientPrint or what ?
Note that all previews before printing are good with all printers, but with the "Printer 2" and "Printer 3" set to default, the printed report was not the one i saw into the Preview.
Below a link to a sample report that we have. All our reports have the same global dimensions.
http://pages.videotron.com/poulinst/report.zip
My company has a .Net app that embeds the reportwriter for displaying (and printing) reports. This seems to work fine visa vis printing reports in landscape mode, although odly if you look at the printer properties it SAYS it is priting in portrait. In any case, the problem comes when this default reportwriter isn't used but rather an rdl file is generated programmatically. No matter what width and height settings we use, the document unfailingly prints in portrait mode. I've looked to see whether there is any way to force the printer mode, but it seems there isn't, at least not through an rdl. Or what SHOULD work (setting the width larger than the heigh) does not. I'm wondering if anyone else here has run into difficulties like this if there are any solutions or places I might look for answers? Thanks!
View 1 Replies View RelatedCan anyone help on this topic...
i need to set Printer Delivery Extension, and create a subscription for report which will be sent to the printer automatically
Hi,
I have a string almost 11006 length.. when i try to send back from SQLCLR procedure
it says cannot send ..
here is Exception Text "Message length 11060 exceeds maximum length supported of 4000."
Max limit to send a string using pipe is 4000
How I can send a string which is large in size than 4000.
Thanks
Hello All,
Hopefully someone out there will have an idea as this is driving me nuts.
I want to send a dynamic files in attachment files ny send mail task that file name has change follow datetime.
I try to use the expression but I can't use it.
please tell me for this problem.
Any suggestions appreciated,
Thanks.
This is my procedure which I need to send the Data into Database, But it does not generate any error and it does not send the information into Database, May I have done wrong, any one to look on that please.
Sub Add_To_Cart(ByVal Src As Object, ByVal Args As EventArgs)
Dim FVProductID As Label = FormView1.FindControl("ProductID")
Dim FVProductName As Label = FormView1.FindControl("ProductName")Dim FVProductPrice As Label = FormView1.FindControl("ProductPrice")
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim sql As String
Dim SQLAddString As String
DBConnection = New SqlConnection("Data Source=MANDARISQLEXPRESS;Initial Catalog=SHOES;Integrated Security=True")
DBConnection.Open()
If Not Session("OrderID") Is Nothing Then
sql = "SELECT Count(*) FROM ShoppingCart " & _
"WHERE OrderID = '" & CType(Session("OrderID"), String) & "' " _
& "AND ProductID = '" & FVProductID.Text & "'"
DBCommand = New SqlCommand(sql, DBConnection)
If DBCommand.ExecuteScalar() = 0 Then
SQLAddString = "INSERT INTO ShoppingCart (OrderID, ProductID, OrderDate, ProductName, ProductQnty, ProductPrice) VALUES (" & _
"'" & Session("OrderID") & "', " & _"'" & FVProductID.Text & "', " & _
"'" & Today & "', " & _"'" & FVProductName.Text & "', " & _
"'" & FVProductPrice.Text & "', 1)"DBCommand = New SqlCommand(SQLAddString, DBConnection)
DBCommand.ExecuteNonQuery()
End If
End If
DBConnection.Close()
Src.Text = "Item Added"Src.ForeColor = Color.FromName("#990000")
Src.BackColor = Color.FromName("#E0E0E0")
Src.Font.Bold = True
End Sub
Sub Add_To_Cart(ByVal Src As Object, ByVal Args As EventArgs)
Dim FVProductID As Label = FormView1.FindControl("ProductID")
Dim FVProductName As Label = FormView1.FindControl("ProductName")
Dim FVProductPrice As Label = FormView1.FindControl("ProductPrice")
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim sql As String
Dim SQLAddString As String
DBConnection = New SqlConnection("Data Source=MANDARISQLEXPRESS;Initial Catalog=SHOES;Integrated Security=True")
DBConnection.Open()
If Not Session("OrderID") Is Nothing Then
sql = "SELECT Count(*) FROM ShoppingCart " & _
"WHERE OrderID = '" & CType(Session("OrderID"), String) & "' " _
& "AND ProductID = '" & FVProductID.Text & "'"
DBCommand = New SqlCommand(sql, DBConnection)
If DBCommand.ExecuteScalar() = 0 Then
SQLAddString = "INSERT INTO ShoppingCart (OrderID, ProductID, OrderDate, ProductName, ProductQnty, ProductPrice) VALUES (" & _
"'" & Session("OrderID") & "', " & _
"'" & FVProductID.Text & "', " & _
"'" & Today & "', " & _
"'" & FVProductName.Text & "', " & _
"'" & FVProductPrice.Text & "', 1)"
DBCommand = New SqlCommand(SQLAddString, DBConnection)
DBCommand.ExecuteNonQuery()
End If
End If
DBConnection.Close()
Src.Text = "Item Added"
Src.ForeColor = Color.FromName("#990000")
Src.BackColor = Color.FromName("#E0E0E0")
Src.Font.Bold = True
End Sub
I need to send an email for each row in a dataset. The data set will contain the order number. I need to first look up the order detail based on the order number and put it into an e-mail. Should I use the OLE DB command object for this?
View 3 Replies View RelatedI have set up a multiple server merge replication publication using the following:
SQL server running SQL Server 2005 (SQL server ce server tools installed)
Web Server running IIS (Required replication elements installed)
All went smoothly with the installation and I was able to running the diagnostics report from my Pocket PC by browsing the web page url that contains the slqcesa30.dll
http://www.myserver.eu/repdata/sqlcesa30.dll
I then ran the configure web synchronization wizard and setup basic authentication (I am using this purely for test purposes and will reconfigure the security when testing is complete) I then created a user on both the SQL server and the Web Server (identical on both machines) and gave this user the required rights in all objects. I have set up a trial application using visual studio 2005 vb.net on a windows mobile 5 device. When form1 loads the following code is fired:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'' Configure the DataAdapter for use in UI binding
cnField = New SqlCeConnection("Data Source =documents and settingsMobileData.sdf;")
daField = New SqlCeDataAdapter("SELECT Id, LatLong, Dateandtimeoffix FROM FieldData", cnField)
'' Configure the update comand
Dim cb As New SqlCeCommandBuilder(daField)
Merge()
End Sub
Private Sub Merge()
Const URL As String =€? http://www.myserver.eu/repdata/sqlcesa30.dll€?
'' URL to Agent
Const InterNetUser As String = "Fielddata" '' InternetUser
Const InternetPassword As String = "Password" '' InternetPassword
Const PublisherServer As String = "MyServer" '' Publisher server
Const PublisherDatabase As String = "Table_Test" '' Publisher Database
Const PublicationName As String = "RepData" '' Publication name
Const SubscriberName As String = "Testing" '' Subscriber name
Const LocalDB As String = "Data Source=documents and settingsMobileData.sdf" ''Connection string to local database
Using rep As New SqlCeReplication(URL, InterNetUser, InternetPassword, PublisherServer, PublisherDatabase, PublicationName, SubscriberName, LocalDB)
Try
If Not System.IO.File.Exists("Documents and SettingsMobileData.sdf") Then
rep.AddSubscription(AddOption.CreateDatabase)
End If
rep.Synchronize()
Catch ex As SqlCeException
DisplaySQLCEErrors(ex)
End Try
End Using
SetupDataSetforUI()
End Sub
When the code executes I obtain the following error:
Index #0
Microsoft SQL Server 2005 Mobile Edition
Error: A request to send data to the computer running IIS has failed for more information see HRESULTS.
I have looked this up and it appears to be to do with certification? Is this correct I am using HTTP not HTTPS?
Any assistance appreciated
joebo
Hello all,
We have a Windows 2003 Web Edition server serving a site through IIS. It connects to a Windows 2003 Standard Edition server running SQL 2000 SP3a.
This site receives the following error as seen in the topic:
[DBNETLIB][ConnectionRead (recv()).]General network error. Check your network documentation.
We've configured the server network utility to only allow TCP/IP connections. The connection string for the site is as follows:
<%
' FileName="Connection_ado_conn_string.htm"
' Type="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
MM_connSpankMSSQL_STRING = "Provider=sqloledb;Data Source=SERVER_IP,1433;Network Library=DBMSSOCN;Initial Catalog=ourmaindb_1;User ID=ourmaindb_1;Password=hotcookies;"
%>
Any ideas or tips on solving this issue? We've noticed it is due to larger queries as smaller ones do work with no problems.
The servers are behind a BSD box running iptables, has 1433,1434 along with standard web ports wide open. Anything outbound is allowed.
Some further testing via ODBC on the IIS server improved things. No more connection pooling for the SQL Server driver allows for 1/3 of the query to run. Still 2/3s of it doesn't show up, and that general network error message appears.
Should have 330 rows if it works right.
Hi
While running a DTS, many times the error message: "[DBNETLIB][ConnetionWrite (WrapperWrite()).]General network error. Check your network documentation." appears.
Does somebody knows why?
I am running the DTS from a computer (not the server where the DTS is stored) and it is connected without any problem when this happens.
Thanks!!
Regards
Lautaro - Argentina.
i currently have multiple textboxes which input data, i'm wanting the textbox details to be sent to a database, here's how one of the textboxes look: <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Visible="False" Width="300px"></asp:TextBox>
the sqldatasource:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CommunityDirConnectionString %>" InsertCommand="INSERT INTO email(Name, Department, Email, Subject, Body) VALUES (@Name, @Department, @Email, @Subject, @Body)" SelectCommand="SELECT email.* FROM email"><InsertParameters><asp:Parameter Name="Name" /><asp:Parameter Name="Department" /><asp:Parameter Name="Email" /><asp:Parameter Name="Subject" /><asp:Parameter Name="Body" /></InsertParameters></asp:SqlDataSource>
i'm wanting it to fire once the user selects a button, but i'm not sure what code needs to be placed behind the button?
I want to post all the data in my company branch office in Lahore to the Head office in Peshawar. This will be done at the end of the day and the two SQL SERVERs synchronize data between both points over internet. what procedure should i use? and how the two computers will know the ip addresses of each other while connecting?
View 3 Replies View RelatedHow yould i loop trought all the records in a table and fetching a specic record that is flagged and sending for each record found a email with that records data to a mail recipient. this should be part of a step in a sql job. PLZ HELP
View 2 Replies View Related