SQL Insert In Aspx.vb File (or Share Variable With .aspx Page)
Mar 14, 2008
Hi,
I have a form page with an insert like this:
<asp:SqlDataSource ID="addProductDataSource" runat="server"
InsertCommand="INSERT INTO test(
title1,
firstName1,
lastName1,
dateOfBirth
) VALUES (
@title1,
@firstName1,
@lastName1
@dateOfBirth
)"
ConnectionString="<%$ ConnectionStrings:yourQuoteCentreConnectionString %>">
<InsertParameters>
<asp:ControlParameter ControlID="dateOfBirth" Name="dateOfBirth" Type="DateTime" />
<asp:ControlParameter ControlID="title1" Name="title1" PropertyName="Text" />
<asp:ControlParameter ControlID="firstName1" Name="firstName1" PropertyName="Text" />
<asp:ControlParameter ControlID="lastName1" Name="lastName1" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
In default.aspx.vb I have:
Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
'CREATE DATETIME FROM USERS BIRTH DATE
Dim dateOfBirth As New System.DateTime(applicantYear.SelectedValue, applicantMonth.SelectedValue, applicantMonth.SelectedValue, 0, 0, 0)
'INSERT TO DATABASE
addProductDataSource.Insert()
End Sub
I would like to reference the variable dateOfBirth created in default.aspx.vb in the insert query on the page, or ideally move the insert query into the aspx.vb page. Would this make more sense to do?
Thanks,
Paul
Hi can someone help me? I'm using Access database and Microsoft VS2005 (VB) I need to take data from 2 different tables in 1 database. But i can't seems to get it right! I have: - dbWarehouse.mdb- tblReadDetails and tblStock I need to use "Barcode" from tblReadDetails, compare it with "Barcode" in tblStock then retrieve all the column in tblStock and put it in a webpage.aspx list box. I tried the following code...cn.ConnectionString = strConncn.Open()cmd = New OleDbCommand("SELECT tblStock.Barcode, tblStock.Item, tblStock.Dept, tblReadDetails.Barcode FROM tblStock JOIN tblReadDetils WHERE tblReadDetails.Barcode = tblStock.Barcode", cn)dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)While dr.Read()lstBarcode.Items.Add(dr2.Item("tblStock.Barcode"))lstItem.Items.Add(dr2.Item("tblStock.Item"))lstDept.Items.Add(dr2.Item("tblStock.Dept"))End While but it prompt me the following error... OleDbException was unhandled by user codeSyntax error in FROM clause What's wrong with this code? Regards and thanks!
Being new to ASP.NET, I may be asking something that is dead simple, but please bear with me!
How would I go about listing all the tables, stored procedures and views from a SQL database within an aspx page? I understand how to connect and return a dataset etc, but that's about as far as I can get. I want to be able to list all of these objects from a given db - any ideas?
Additionally (this may not be possible) - is there a way I can list all of the objects within a visual studio.net solution, again within an aspx page?
I am trying to use session in my asp.net in moss but i got the error below, eventhough i have set web.config file to enableSessionState="true" and include €œSystem.Web.SessionState.SessionStateModule". Have i miss anything? thanks
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \ section in the application configuration.
Dear i am using visual studio.net.......... when i connect database (in sqlserver) using sqldataAdapter with datagrid in visual basic.net every thing work properly........... but when i use the same in asp.net then i get an error message on the resultant explorer page give below.
Server Error in '/studentData' Application. --------------------------------------------------------------------------------
Login failed for user 'RAMIZSARDARASPNET'. 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: Login failed for user 'RAMIZSARDARASPNET'.
Source Error:
Line 85: 'Put user code to initialize the page here Line 86: Dim ds As New DataSet() Line 87: SqlDataAdapter1.Fill(ds) Line 88: DataGrid1.DataSource = ds.Tables(0) Line 89: DataGrid1.DataBind()
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0
Plz solve my problem and Reply me on ramiz_ch@hotmail.com Plz solve my problem and Reply me on ramiz_ch@hotmail.com Plz solve my problem and Reply me on ramiz_ch@hotmail.com
I am using Sql server reporting services.When i have create a report .rdl file and deploy it on Report server and than display that report on my application's .aspx page in pdf format using web services , every thing is perfactly working in my senario at the starting time but now i faced a problem with that. When record goes more than 2000 (in my senario a single record disply in a one report pdf page means for 2000 record in table that means its display in 2000 pdf page as with next forward option of pdf view),So in that cas it doesn't work, did now show any report and give the error as ex.Message"Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error message: -- <?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Server Unavailable </title> </head> <body> <h1><span style="font-family:Verdana;color: #ff3300">Server Application Unavailable </span></h1> <p> <span style="font-family:Verdana;"> The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request. </span></p> <p> <b>Administrator Note: </b> An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur. </p> </body> </html>
--."string
Any body have any idea please help me as soon as possible. urgently--- any help will be appriciate. thanks in advance. arvind
Hi How to bring Report builder in the Ui of .net aspx pages? I tryed withe the .exe but it is comming with a new process and come up with new IDE of Report builder, i donot required this, I want it should come up within the Aspx page itself.
I created a report with a parameter. The parameter was created using a dataset in the report designer. This works fine. I deployed the report (webhost4life) and the report runs fine in the report manager. I am able to select my casenumber click on the default view report button and it works.
Problem: I embedd the report into an aspx page frmReports1.aspx. I call this page from another page (form). the frmReports.aspx page comes up and displays the default drop down list box with the casenumbers (fine). I select the casenumber and click on the view report button and NOTHING. I here the postbacks taking place but all that happens is the default value appears in the drop down list box and the toolbar shows. I checked permissions and everything is fine. I searched the forum and thought i found the solution with the inLine HTML and Async (still nothing) I can only think that something is not going right with the parameter. Here is my html, and code behind code. any help would be greatly apprcieated.
Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef userName As String, ByRef password As String, ByRef authority As String) As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials
End Function
End Class
Public Function GetFormsCredentials(ByRef authCookie As Cookie, _
ByRef userName As String, _
ByRef password As String, _
ByRef authority As String) _
As Boolean
authCookie = Nothing
userName = Nothing
password = Nothing
authority = Nothing
'Not using form credentials
Return False
End Function
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
'ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
'rvTest.ServerReport.Refresh()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
rvTest.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
My stored proceddure "My Programs" includes a parameter @meid.How do I code an aspx file to run the procedure with a user ID, e.g. EmpID?I tried the following codes, but the error message indicated it can not findthe Stored Procedure. How do I pass the EmpID as a Stored Procedure parameter? <%meid = EmpIdcmd.CommandText = "MyPrograms meid"cmd.CommandType = CommandType.StoredProcedurecmd.Connection = sqlConnection2sqlConnection2.Open()reader3 = cmd.ExecuteReader(meid)While reader3.Read()sb.Append(reader3(i).ToString() + "......<BR> <BR /> ")End While%> TIA,Jeffrey
Hello, I have the following stored procedure and the following aspx page. I am trying to connect this aspx page to the stored procedure using the SqlDataSource. When the user enters a branch number in textbox1, the autonumber generated by the database is returned in textbox2. I am not quite sure what to do to get this to execute. Can someone provide me assistance? Will I need to use some vb.net code behind? Stored ProcedureCREATE PROCEDURE InsertNearMiss @Branch Int, @Identity int OUT ASINSERT INTO NearMiss (Branch)VALUES (@Branch) SET @Identity = SCOPE_IDENTITY() GO
I have a stored procedure when query a big table about 500,000 records. When I run the stored procedure in the query analyzer, it is very fast and it only takes 2~3 seconds. However, when my aspx page try to call this stored-procedure with a Command's ExecuteReader method like bellow:
I always get timeout expired exception. I try to set the connection timeout and command timeout to 100 seconds. The exception is gone but the average execution time is about 25 seconds! While the stored-procedure only takes about 2~3 seconds in query analyzer with the same parameter.
What could be the problem?? I tried to figure this out for a couple days but still no clue.
I have a table which gets updated roughly every 6 seconds with data. I have setup an aspx page with a datagrid to meta tag refresh every 3 seconds.
Because the data sometimes stops for a couple of minutes or even hours, I was thinking of a way to update/refresh the aspx page only when the table data gets entered ( to stop page flickering every 3 seconds).
I was thinking about a stored procedure and using an on update procedure.
Does anyone have any preffered methods or suggestions on the best way to accomplish this task.
Hello,I stuck in a delimma.Where to put the business logic that involves only one updatebut N number of selects from N tables........with N where conditions
I am trying to embed a Reporting Services Report in a aspx page. I have the report embedded in the page but I am having difficulty passing a parameter to the report and getting the report to run within the page. Any information is appreciated.
I have used Report viewer control to show ssrs 2005 report in my aspx page. Can we show the SSRS 2005 report on the aspx page in any other way? any info on this is appreciated.
I am getting the following error message when I try to execute a SSIS package from an asp.net page written in C# 2.0. What I am trying to do is basically just click on a button in the web page and it will execute the package. The code to execute the package is pretty simple. I pass the path of the DTS package stored in the local folder. This works fine in the machine where SQL2005 is installed locally. But it fail when I have a seperate Web Server and SQL Server. Any ideas? Do I have to install SSIS or SQL2005 on a web server as well?
Thanks
static public string Execute_SSIS_DTS(string DTS_Path)
{
Microsoft.SqlServer.Dts.Runtime.Application app;
app = new Microsoft.SqlServer.Dts.Runtime.Application();
Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.
Line 226: static public string Execute_SSIS_DTS(string DTS_Path) Line 227: { Line 228: Application app = new Application(); Line 229: Package package = app.LoadPackage(DTS_Path, null); Line 230: DTSExecResult result = package.Execute();
[COMException (0x80040154): Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.] Microsoft.SqlServer.Dts.Runtime.Application..ctor() +43
[DtsPipelineException: Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.] Microsoft.SqlServer.Dts.Runtime.Application..ctor() +169 Utilities.Execute_SSIS_DTS(String DTS_Path) in c:InetpubwwwrootMasterTablesApp_CodeUtilities.cs:228 MasterTables_Admin_MasterTables_LOINC_External.btn_SyncLISTest_Click(Object sender, EventArgs e) in c:InetpubwwwrootMasterTablesMasterTables_CustomMasterTablesCustom_LOINC_External.aspx.cs:98 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +114 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +141 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +32 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3215
I'm having problems displaying images generated by aspx pages from a report. It works fine if I point the external value to a static image on the web. I can paste the url to the page into IE and it generates the image with no issues. What am I doing wrong? I used a textbox to verify that the correct url is being generated (= Parameters!MYPROJECT_URL.Value & Parameters!MYPROJECT_NO.Value).
Are there any issues with generating external images with reporting services?
I have installed SP1 for MS 2005...shouldn't I see some sort of visual confirmation in Management studio when I click the Help Menu->about? saying the version is MS SQL Server 2005? how do I verify that the upgrade was successful?
Hi All i have created one report using SSRS 2005, in this report one parameter is multivalue parameter, this report preview working fine and user able to select multivalues. but the problem is i deployed this report in server and opened in client system (reports shown to user using report viewer in aspx pages), i am able to access the report but multivalue parameter dropdown is not working. when i clicked on multivalue parameter dropdown report refreshing and remaining parameters default vaues coming up.. i am unable to find the solution please anyone help me
hi friends, i need a code for storing and receiving an image to/fro SQL SERVER 2000 (in C#). i had searched some sites, all are in VB for windows forms not for website. finally i got a code from some site. it is working for storing purpose. not working for receiving purpose. the code for receiving and displaying purpose is (in a fresh page) private void Page_Load(object sender, System.EventArgs e){ // Put user code to initialize the page here MemoryStream stream = new MemoryStream (); SqlConnection connection = new SqlConnection (@"server=INDIAINDIA;database=iSense;uid=sa;pwd=india"); try { connection.Open (); SqlCommand command = new SqlCommand ("select Picture from Image", connection); byte[] image = (byte[]) command.ExecuteScalar (); stream.Write (image, 0, image.Length); Bitmap bitmap = new Bitmap (stream); Response.ContentType = "image/gif"; bitmap.Save (Response.OutputStream, ImageFormat.Gif); } finally { connection.Close (); stream.Close (); }}what s the problem is.........i'm getting an exception at Bitmap instantiation.(i.e Bitmap bitmap = new Bitmap (stream);)exception is "Parameter is not valid" what is the problem with that coding? was it correct? do u have any code for this in C#? if so, pls provide that......help me........pls.............
Dear all, I have the Following Query:SELECT DATEDIFF(day, GETDATE(), RECENT_RESERVATION)AS Expr1,RECENT_RESERVATION FROM EMP WHERE SUN=empName;when i run it inside the query analyzer, it returns two columns. but if run it inside The ASPX page it retuns only one column wich is RECENT_RESERVATION date.Note: i am using one methode that takes care of reading from SQL and assigning the result into an array, it works fine everywhere, but with this query it dosen't work. Any suggestions??
Hi all,Anyone can show me how can I catch the 'Print' statement that I have defined in my store procedure using SQL server 2000 DB on the .aspx page? ( I am using ASP.NET 1.0)My store procedure as follow:CREATE PROC NewAcctType(@acctType VARCHAR(20))ASBEGIN --checks if the new account type is already exist IF EXISTS (SELECT * FROM AcctTypeCatalog WHERE acctType = @acctType) BEGIN PRINT 'The account type is already exist' RETURN END BEGIN TRANSACTION INSERT INTO AcctTypeCatalog (acctType) VALUES (@acctType) --if there is an error on the insertion, rolls back the transaction; otherwise, commits the transaction IF @@error <> 0 OR @@rowcount <> 1 BEGIN ROLLBACK TRANSACTION PRINT 'Insertion failure on AcctTypeCatalog table.' RETURN END ELSE BEGIN COMMIT TRANSACTION ENDENDThanks for all your replies
I have aspx page which uses Reportviewer object to execute/display reporting services report on the page based on the parameters passed by the aspx page.
It works fine. I have a problem when I try to use import option on that page. It throws the following error. Can anybody help me to resolve this issue?
Advanct thanks for your help and support
Thanks,
Sundar
Here is the error message when I export the report to any format (Excel, pdf, csv or text) For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method. 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.Xml.XmlException: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method.
Here is the code: ASPX Code: <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="100%" ProcessingMode="Remote" Width="100%" ShowFindControls="false" ShowPageNavigationControls="true" ShowPromptAreaButton="false" AsyncRendering="false" EnableViewState="true" ShowParameterPrompts="false" Visible="false"> <ServerReport ReportServerUrl="http://miscsql1/ReportServer" ReportPath="/webreports/POS Commission Report"></ServerReport> </rsweb:ReportViewer>
ASPX.VB Code Dim RptParameters(2) As Microsoft.Reporting.WebForms.ReportParameter RptParameters(0) = New Microsoft.Reporting.WebForms.ReportParameter("Repcode", objCommon.RepSite.ToString, False) RptParameters(1) = New Microsoft.Reporting.WebForms.ReportParameter("StartDate", txtStartDate.Text.ToString) RptParameters(2) = New Microsoft.Reporting.WebForms.ReportParameter("EndDate", txtEndDate.Text.ToString) ReportViewer1.ServerReport.SetParameters(RptParameters) ReportViewer1.ServerReport.Refresh() ReportViewer1.Visible = True objCommon = Nothing
Hi everyone, I use the forms authetification for my report manager and server. But, i have this problem : The Logon page running successfully but redirect to Folder.aspx not happening
To clarify:
>I get the logon page (UILogon.aspx)
>My user has been registered ok (i have checked the entry in the db to make sure it was created)
>I enter the login & password correctly and page posts back
The redirect never happens - In the browser, it never leaves the UILogon.aspx
Using Win2003, SQL Server 2005, Reporting Services