Is there some recommended way to clean input before submitting it to the database? We'd like to develop a library that can be used on our ASP/ASP.NET apps to filter input before it's sent to the SQL Server and Oracle databases. Is there a way to create a .NET DLL that can be used for both ASP.NET and classic ASP apps. Thanks.
Hi, I'm not very asp.net savy and could not find any solid examples of what I need done. I have one text box on my page and one submit button. I would like the information entered from the text box to go into a SQL database when clicking on the submit button. I'm not sure what the exact coding should be in order to get this operating the way I want. I'm coding in VB, this is what I have so far:<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"><title>Untitled Page</title> <script language="javascript" type="text/javascript"> // <!CDATA[function Submit1_onclick() { } // ]]></script> </head> <body> <form id="form1" runat="server"> <div> <input id="Text1" type="text" /><br /> <input id="Submit1" type="submit" value="submit" onclick="return Submit1_onclick()" /></div></form> </body> </html> Thanks, Derek
I have a form setup, the code of which is listed below, and I would like to be able to submit the data that is entered in the form to a SQL 2005 standard database via the SqlDataSource control and a button. I'm just having trouble doing so because of the coding. Any help or suggestions would be greata s I've already read through the tutorials on this site and they don't go in depth very much. Thanks! <%@ Page Language="VB" %> <%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls" TagPrefix="BDP" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.SqlClient" %> <Script runat="server"> Private Sub InsertData(ByVal Source As Object, ByVal e As EventArgs) SqlDataSource1.Insert() End Sub </Script>
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Weston E-Vault - New Customer Sign-Up Form</title> </head> <body> <form id="form1" runat="server"> <div style="text-align: center"> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=C26819_24561;Initial Catalog=ebackups;Integrated Security=True;User Instance=False" ProviderName="System.Data.SqlClient" InsertCommand="INSERT INTO backup_info(cust_name, cust_phone, cust_contact, cust_analyst, storage_plan, install_date, backup_data, backupexec_option, backup_program, cust_email) VALUES (@cust_name, @cust_phone, @cust_contact, @cust_analyst, @storage_plan, @install_date, @backup_data, @backupexec_option, @backup_program, @cust_email)"> <InsertParameters> <asp:ControlParameter ControlID="DropDownList1" DefaultValue="" Name="@cust_name" PropertyName="SelectedValue" /> <asp:ControlParameter ControlID="TextBox1" Name="@cust_contact" PropertyName="Text" /> <asp:ControlParameter ControlID="TextBox2" Name="@cust_phone" PropertyName="Text" /> <asp:ControlParameter ControlID="DropDownList3" Name="@cust_analyst" PropertyName="SelectedValue" /> <asp:ControlParameter ControlID="BDPLite1" Name="@install_date" PropertyName="Controls" /> <asp:ControlParameter ControlID="TextBox3" Name="@cust_username" PropertyName="Text" /> <asp:ControlParameter ControlID="TextBox4" Name="@cust_password" PropertyName="Text" /> <asp:ControlParameter ControlID="DropDownList2" Name="@storage_plan" PropertyName="SelectedValue" /> <asp:ControlParameter ControlID="TextBox5" Name="@backup_data" PropertyName="Text" /> <asp:ControlParameter ControlID="RadioButtonList1" Name="@backupexec_option" PropertyName="SelectedValue" /> <asp:ControlParameter ControlID="TextBox6" Name="@backup_program" PropertyName="Text" /> <asp:ControlParameter ControlID="TextBox7" Name="@cust_email" PropertyName="Text" /> </InsertParameters> </asp:SqlDataSource> <br /> <br /> <br /> <table> <tr> <td style="width: 100px"> <img src="/images/westonevault_logo.jpg" /></td> <td style="width: 703px; text-align: right"> <asp:Button ID="Button1" runat="server" BackColor="White" BorderColor="Navy" BorderStyle="Solid" BorderWidth="1px" Font-Names="verdana" Font-Size="Small" ForeColor="Navy" PostBackUrl="~/secure/tech_home.aspx" Text="Back" /><span style="font-size: 8pt; color: #000099"> </span></td> </tr> </table> <br /> <br /> <img src="/images/div.jpg" style="font-size: 8pt; color: #000099" /><br /> <br /> <div style="text-align: center"> <table style="font-size: 8pt; width: 730px; color: #000099; font-family: Verdana"> <tr> <td colspan="3" style="font-weight: bold; font-family: Verdana; text-align: left"> <span style="color: #000099">Customer Information<br /> </span> <hr style="color: #000099" /> <span style="font-weight: normal; font-size: 8pt; color: #000099">Please enter all customer data as accurately as possible. Any incorrect information on this form may result in incorrect data being backed up, reports not reaching the customer or they may<span style="font-size: 12pt"><strong> </strong><span style="font-size: 8pt">not receive the need</span></span>ed amount of disk space.<br /> <br /> </span> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px; text-align: left"> <span style="font-family: Verdana"><span style="color: navy">Customer Name:<br /> </span> <asp:DropDownList ID="DropDownList1" runat="server" DataValueField="cust_name" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Navy" Width="178px"> <asp:ListItem Selected="True">Select Customer Name.....</asp:ListItem> <asp:ListItem>Alaska Road Boring</asp:ListItem> <asp:ListItem>Allen and Peterson</asp:ListItem> <asp:ListItem>AK Guns</asp:ListItem> <asp:ListItem>ATS Alaska</asp:ListItem> <asp:ListItem>BC Contractors</asp:ListItem> <asp:ListItem>Bek of Alaska</asp:ListItem> <asp:ListItem>Brokentop Community Assoc.</asp:ListItem> <asp:ListItem>COHRA</asp:ListItem> <asp:ListItem>Crisis Pregnancy Center</asp:ListItem> <asp:ListItem>Gaines and Co.</asp:ListItem> <asp:ListItem Value="Gil Damond">Gil Damond</asp:ListItem> <asp:ListItem>GMW Fire</asp:ListItem> <asp:ListItem>Integrity Funding</asp:ListItem> <asp:ListItem>La Pine Community Clinic</asp:ListItem> <asp:ListItem>La Pine Fire District</asp:ListItem> <asp:ListItem>Lumbermens Ins.</asp:ListItem> <asp:ListItem>Murray</asp:ListItem> <asp:ListItem>NEI</asp:ListItem> <asp:ListItem>Northstar Center</asp:ListItem> <asp:ListItem>Redi Electric</asp:ListItem> <asp:ListItem>Robberson Ford</asp:ListItem> <asp:ListItem>South Anchorage District Office</asp:ListItem> <asp:ListItem>St. George Tanaq</asp:ListItem> <asp:ListItem>Stinebaugh</asp:ListItem> <asp:ListItem>THT Electric</asp:ListItem> <asp:ListItem>Watterson</asp:ListItem> <asp:ListItem>United Auto</asp:ListItem> <asp:ListItem>Weston - ANC</asp:ListItem> <asp:ListItem>Weston - BND</asp:ListItem> <asp:ListItem></asp:ListItem> </asp:DropDownList><br /> </span> </td> <td style="width: 187px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">Customer Contact:<br /> </span> <asp:TextBox ID="TextBox1" runat="server" Font-Names="Verdana" Font-Size="X-Small" Width="164px"></asp:TextBox><br /> </span> </td> <td style="width: 136px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">Customer Phone:<br /> </span> <asp:TextBox ID="TextBox2" runat="server" Font-Names="verdana" Font-Size="X-Small"></asp:TextBox><br /> </span> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">Customer E-Vault Username:<br /> </span> <asp:TextBox ID="TextBox3" runat="server" Font-Names="Verdana" Font-Size="X-Small" Width="150px"></asp:TextBox><br /> </span> </td> <td style="width: 187px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">Customer E-Vault Password:<br /> </span> <asp:TextBox ID="TextBox4" runat="server" Font-Names="Verdana" Font-Size="X-Small" TextMode="Password" Width="150px"></asp:TextBox><br /> </span> </td> <td style="width: 136px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">E-Vault Storage Plan:<br /> </span> <asp:DropDownList ID="DropDownList2" runat="server" DataValueField="storage_plan" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Navy"> <asp:ListItem Selected="True">Select Plan.....</asp:ListItem> <asp:ListItem>0-300MB</asp:ListItem> <asp:ListItem>300MB-2GB</asp:ListItem> <asp:ListItem>2GB-4GB</asp:ListItem> <asp:ListItem>4GB-6GB</asp:ListItem> <asp:ListItem>6GB-8GB</asp:ListItem> <asp:ListItem>8GB-15GB</asp:ListItem> <asp:ListItem>15GB-25GB</asp:ListItem> <asp:ListItem>25GB-35GB</asp:ListItem> <asp:ListItem>35GB-50GB</asp:ListItem> <asp:ListItem>50GB-100GB</asp:ListItem> <asp:ListItem>100GB-200GB</asp:ListItem> </asp:DropDownList><br /> </span> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">Analyst:<br /> </span> <asp:DropDownList ID="DropDownList3" runat="server" DataValueField="cust_analyst" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Navy" Width="162px"> <asp:ListItem>Select Analyst.....</asp:ListItem> <asp:ListItem>Brock McFarlane</asp:ListItem> <asp:ListItem>Cameron Farrally</asp:ListItem> <asp:ListItem>Chad Huls</asp:ListItem> <asp:ListItem>Eric Spinney</asp:ListItem> <asp:ListItem>Greg Freeman</asp:ListItem> <asp:ListItem>Harald Smit</asp:ListItem> <asp:ListItem>Kevin Mark</asp:ListItem> <asp:ListItem>Mark Anderson</asp:ListItem> <asp:ListItem>Mike Murphy</asp:ListItem> <asp:ListItem>Tim Elder</asp:ListItem> </asp:DropDownList><br /> </span> </td> <td style="width: 187px; text-align: left"> <span style="font-family: Verdana"><span style="color: #000099">Today's Date: (mm/dd/yyy)<br /> </span> <bdp:bdplite id="BDPLite1" runat="server" borderstyle="None" cssclass="bdpLite" dateformat="ShortDate" font-bold="False" font-names="verdana" font-size="X-Small" forecolor="Navy" selecteddate=""></bdp:bdplite> </span> </td> <td style="width: 136px; text-align: left"> <br /> </td> </tr> <tr style="font-size: 8pt"> <td colspan="3"> </td> </tr> <tr style="font-size: 8pt"> <td colspan="3" style="text-align: left"> <span style="font-family: Verdana"><span style="color: #000099"><strong> <br /> Backup Data<br /> <hr style="color: #000099" /> </strong><span>Please enter all directories and/or files and folders the customer wishes to have backed up. Be thourough yet brief as this is for historical and record keeping purposes.<br /> <br /> </span></span></span> </td> </tr> <tr style="font-size: 8pt"> <td colspan="3" style="text-align: left"> <asp:TextBox ID="TextBox5" runat="server" ForeColor="#000000" Height="130px" MaxLength="200" TextMode="MultiLine" Width="503px"></asp:TextBox><br /> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px"> </td> <td style="width: 187px"> </td> <td style="width: 136px"> </td> </tr> <tr style="font-size: 8pt"> <td colspan="3" style="text-align: left"> <span style="font-family: Verdana"><span style="color: #000099"><strong> <br /> BackupExec / NTBackup<br /> <hr style="color: #000099" /> </strong><span>Does the customer have another backup program running that backs up their files to tape or another physical media.<br /> <br /> </span></span></span> </td> </tr> <tr style="font-size: 8pt"> <td colspan="2" style="height: 41px; text-align: left"> <asp:RadioButtonList ID="RadioButtonList1" runat="server" Font-Names="Verdana" Font-Size="X-Small" ForeColor="Navy" RepeatDirection="Horizontal" Width="127px"> <asp:ListItem Value="Yes">Yes</asp:ListItem> <asp:ListItem Value="No">No</asp:ListItem> </asp:RadioButtonList><span style="font-family: Verdana"><span style="color: #000099">If "Yes", what program do they use?</span> <asp:TextBox ID="TextBox6" runat="server" Font-Names="Verdana" Font-Size="X-Small" Width="200px"></asp:TextBox><br /> </span> </td> <td style="width: 136px; height: 41px"> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px"> </td> <td style="width: 187px"> </td> <td style="width: 136px"> </td> </tr> <tr style="font-size: 8pt"> <td colspan="3" style="text-align: left"> <span style="color: #000099"><span style="font-family: Verdana"><strong> <br /> E-Mail Notifications<br /> <hr style="color: #000099" /> </strong><span>Does the customer wish to receive weekly reports about their backups? (This includes what directories are being backed up, how much storage space they have used on their plan and how much storage space is remaining).If so enter their e-mail address below. If they don't want to receive notifications, you can skip this section.<br /> <br /> </span></span></span> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px; text-align: left"> <asp:TextBox ID="TextBox7" runat="server" Font-Names="Verdana" Font-Size="XX-Small" ForeColor="Navy" Width="201px"> N/A</asp:TextBox></td> <td style="width: 187px"> </td> <td style="width: 136px"> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px"> </td> <td style="width: 187px"> </td> <td style="width: 136px"> </td> </tr> <tr style="font-size: 8pt"> <td style="width: 174px; height: 26px"> </td> <td style="width: 187px; height: 26px; text-align: left"> <asp:Button ID="Button2" runat="server" BackColor="White" BorderColor="Navy" BorderStyle="Solid" BorderWidth="1px" Font-Names="verdana" Font-Size="Small" OnClick="InsertData" Text="Submit Form" /></td> <td style="width: 136px; height: 26px"> </td> </tr> </table> </div> <div style="text-align: center"> <img src="/images/div.jpg" /><br /> <br /> <span style="font-size: 7pt; font-family: Verdana">Copyright 2006 Weston Technology Solutions </span> </div>
Hi everyone, What is the easy way to clean up all ms sql 2005 tables? For example, a database table named Customers which has triggers and primary key and foreign keys. Now I clean up the Customer table using the folowing statement delete Customers And the ms sql 2005 asks me to remove all triggers and foreign keys before allow me to clean up the Customers table. Is there a way to clean up all tables without remove the tiggers and foreign keys? Thanks May
I posted this in the SQL Server Express forum as well...
My app deployed via ClickOnce. It ships with a database creation script which creates the database in the ClickOnce data directory. Upon uninstall, the entire data folder is deleted successfully. But if you then reinstall the app, SQL Server Express still thinks the database exists. Right now, to get a re-install to work, I have to go into Management Studio Express, click on the db (get an pop-up error as the physical db file is no longer there) and then click delete.
So my question is... what system proc should I execute in the db creation script before I run the CREATE DATABASE command?
Hi all , I have a question concering submitting to a SQL database and the error it returns. The purpose of the code is to test connectivity to a SQL database. It works properly because I can change the code to check and return and it does so properly. The code for submissions is below and the elispses represent other code that I took out to keep it short:<%@ Import Namespace="System" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %><%@ Import Namespace="System.Configuration" %> <html> <head> </head> <script language="VB" runat=server> ... Sub SubmitBtn_Click(Sender As Object, E As EventArgs) Dim DS As DataSet Dim MyConnection As SqlConnection Dim MyCommand As SqlDataAdapter MyConnection = New SqlConnection("server=***;database=***;uid=***;pwd=***") MyCommand = New SqlDataAdapter("insert into certifications (name) values ('James Fogarty')", myConnection) DS = new DataSet() MyCommand.Fill(DS, "Titles") MyList.DataSource = DS.Tables("Titles").DefaultView MyList.DataBind() End Sub </script> <body> <center> <form action="default.aspx" method="post" runat="server"> ...
<asp:button text="Save and Submit" OnClick="SubmitBtn_Click" runat="server"/> ... <p> <ASP:DataGrid id="MyList" HeaderStyle-BackColor="#aaaadd" BackColor="#ccccff" runat="server"/> </form> </center> </body> </html> The error I get is:Object reference not set to an instance of an object.Checking the database, I can see that the values were inserted properly. Any suggestions?Thanks - James
Steve McCormick writes "I have written a stored procedure that may be used as a utility. I developed it because I keep having to replicate the content of support data tables between environments when I don't have a link and cannot use the import/export utilities. The procedure generates insert statements that replicate the content of a table. You simply provide the table name as a parameter and it generates an insert statement for each record. The insert statement is dynamic for however many columns the table has and performs appropriate conversions of data to represent how the insert statements should be written. If the table has a primary key, it encases the insert statement in an (IF NOT EXISTS) condition that checks the primary key duplication constraints before attempting the insert. Would you be interested in this tool for your readers and if so, how do I submit it?"
One of my client want to shift his reporting to SSRS. He wants to submit his report requests to SSRS. He wants the report should run at the reporting server side (not on client system) and output should be exported to a folder on server.
I am some what successful in submitting the report requests using subscriptions. But I have no idea to retrieve the requests from SSRS with the execution status.
I have to display all submitted reprot requests with execution status (success or fail) in a data grid and user selects one report to see the out file. Where can I get this information?
And how can I create a subscription that runs immediatly after submission. (without any delay)?
Hello! I'm recieving an error when I submit a form to an Access database. I took this site over from someone else and kept their code as I'm more of a designer than a programmer. If anyone has any ideas as to how to fix it, I would really appreciate it. I'm pretty clueless when it comes to this. I've tried to figure it out on my own, but I seem to be failing. Any help would be great! Here's what I receive when I submit the form:
The ConnectionString property has not been initialized. 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.InvalidOperationException: The ConnectionString property has not been initialized.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[InvalidOperationException: The ConnectionString property has not been initialized.] System.Data.OleDb.OleDbConnection.Open() +203 modern_foods.promotions_form.saveInfo(Object s, EventArgs e) +535 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292 Thank you in advance!
Hi, I'm new around here and am stumped. I have created a form where I submit the information into a SQL Server 2000 table. When I submit the information through the form, only the first character of each field populates inside of the SQL table. This happens for every field except for two, zip and comments. The zip field is numeric and the comments field is text. All the other fields are varchar fields; and these are the fields with the problems. I have attempted to change the data type to text, but that did not work either. I am doing this through a stored procedure I created. Here is the asp code: Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents txtFirstName As System.Web.UI.WebControls.TextBox Protected WithEvents txtLastName As System.Web.UI.WebControls.TextBox Protected WithEvents txtAddress1 As System.Web.UI.WebControls.TextBox Protected WithEvents txtAddress2 As System.Web.UI.WebControls.TextBox Protected WithEvents txtCity As System.Web.UI.WebControls.TextBox Protected WithEvents txtZip As System.Web.UI.WebControls.TextBox Protected WithEvents txtEmail As System.Web.UI.WebControls.TextBox Protected WithEvents txtPhone As System.Web.UI.WebControls.TextBox Protected WithEvents txtComments As System.Web.UI.WebControls.TextBox Protected WithEvents ddlState As System.Web.UI.WebControls.DropDownList Protected WithEvents ddlGift1 As System.Web.UI.WebControls.DropDownList Protected WithEvents ddlGift2 As System.Web.UI.WebControls.DropDownList Protected WithEvents ddlGift3 As System.Web.UI.WebControls.DropDownList Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection() Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand() ' 'SqlConnection1 ' Me.SqlConnection1.ConnectionString = "data source=NDAVENPORT2;initial catalog=Bluestreak;integrated security=SSPI;persi" & _ "st security info=False;workstation id=NDAVENPORT2;packet size=4096" ' 'SqlCommand1 ' Me.SqlCommand1.CommandText = "dbo.[InsertFreeOrders]" Me.SqlCommand1.CommandType = System.Data.CommandType.StoredProcedure Me.SqlCommand1.Connection = Me.SqlConnection1 Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@firstname", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@lastname", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@address1", System.Data.SqlDbType.VarChar, 100)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@address2", System.Data.SqlDbType.VarChar, 100)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@city", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@state", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@zip", System.Data.SqlDbType.Decimal, 9, System.Data.ParameterDirection.Input, False, CType(18, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@email", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@phone", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@item1", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@item2", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@item3", System.Data.SqlDbType.VarChar, 50)) Me.SqlCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@comments", System.Data.SqlDbType.VarChar, 2147483647)) End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click If IsValid Then SqlCommand1.Parameters("@firstname").Value = txtFirstName.Text SqlCommand1.Parameters("@lastname").Value = txtLastName.Text SqlCommand1.Parameters("@address1").Value = txtAddress1.Text SqlCommand1.Parameters("@address2").Value = txtAddress2.Text SqlCommand1.Parameters("@city").Value = txtCity.Text SqlCommand1.Parameters("@state").Value = ddlState.SelectedItem.Text SqlCommand1.Parameters("@zip").Value = txtZip.Text SqlCommand1.Parameters("@email").Value = txtEmail.Text SqlCommand1.Parameters("@phone").Value = txtPhone.Text SqlCommand1.Parameters("@item1").Value = ddlGift1.SelectedItem.Text SqlCommand1.Parameters("@item2").Value = ddlGift2.SelectedItem.Text SqlCommand1.Parameters("@item3").Value = ddlGift3.SelectedItem.Text SqlCommand1.Parameters("@comments").Value = txtComments.Text SqlConnection1.Open() SqlCommand1.ExecuteNonQuery() SqlConnection1.Close() Response.Redirect("Success.aspx") End If End Sub End ClassMy stored procedure looks like this:CREATE PROCEDURE dbo.InsertFreeOrders ( @firstname varchar( 50 ), @lastname varchar( 50 ), @address1 varchar( 100 ), @address2 varchar( 100 ), @city varchar( 50 ), @state varchar( 50 ), @zip numeric, @email varchar( 50 ), @phone varchar( 50 ), @item1 varchar( 50 ), @item2 varchar( 50 ), @item3 varchar( 50 ), @comments text )ASInsert FreeOrders ( o_first_name, o_last_name, o_address_1, o_address_2, o_city, o_state, o_zip, o_email, o_phone, o_item_1, o_item_2, o_item_3, o_comments ) Values ( @firstname, @lastname, @address1, @address2, @city, @state, @zip, @email, @phone, @item1, @item2, @item3, @comments )GOSo it is working, just not completely and I am stumped here. Any help would be great! Thanks.
hy, i wrote an input function to put some data in my database with click of button it doesnt work and i cant find the mistake =/ anyone of you can help? now theres one thing that isnt right, and that is that the datasiz of messagetext is set to max, and here i put it in to 50, cause dont know how to put it to max cause you can only put in ant integer , also in the insert into, i did not put all of the columns cause the data i input is only for certain columns, ( don't think thats a problem) Greetz Roy1 2 Private mocon As clsAdocon 3 Dim naam As String 4 Dim type As String 5 Dim folder As String 6 Dim sUDL = ConfigurationManager.ConnectionStrings("masterConnectionString").ConnectionString 7 8 Protected Sub btnopslaan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnopslaan.Click 9 10 folder = "Out" 11 Select Case True 12 Case rdbMail.Checked 13 type = "Mail" 14 Case rdbFax.Checked 15 type = "Fax" 16 Case rdbSms.Checked 17 type = "Sms" 18 End Select 19 20 If type = "Mail" Then 21 Dim strSql As String 22 strSql = "INSERT INTO Message(ToName, ToEmail, Subject, MessageText, TypeBericht, Folder) VALUES(@ToName,@ToEmail,@Subject,@MessageText,@TypeBericht,@Folder);" 23 24 Try 25 'connectie met database 26 Dim objCn As New SqlConnection(sUDL) 27 Dim objCmd As SqlCommand = objCn.CreateCommand() 28 objCmd.CommandText = strSql 29 30 objCmd.Parameters.Add("@ToName", SqlDbType.NVarChar, 50).Value = naam 31 objCmd.Parameters.Add("@ToEmail", SqlDbType.NVarChar, 50).Value = txtAan.Text 32 objCmd.Parameters.Add("@Subject", SqlDbType.NVarChar, 50).Value = txtOnderwerp.Text 33 objCmd.Parameters.Add("@MessageText", SqlDbType.NVarChar, 50).Value = txtbericht.Text 34 objCmd.Parameters.Add("@Folder", SqlDbType.NChar, 10).Value = folder 35 objCmd.Parameters.Add("@TypeBericht", SqlDbType.NChar, 10).Value = type 36 37 objCn.Open() 38 objCmd.ExecuteNonQuery() 39 objCn.Close() 40 Catch ex As Exception 41 42 End Try 43 End If 44 45 End Sub
Hello, I am writing a website (in vb) to allow for room use reservations and I am looking for a way to compare the selected start and end times which are date-time format to records already in the database for that day/time and specific room. If the selected time does not fall within an already reserved time frame I then want to insert it into the table. I have already written a procedure to do the inserting and that works fine. I just want to validate it before calling the insert. Any ideas? The fields to be validated on the form are textboxes containing date time which populate as read only after the time selection is chosen from dropdown. Thanks in advance It's greatly appreciated.
My name is Syed Kamran Ahmed and i'm an ASP Programmer. I've got a problem with entering values in database from ASP page, if i use apostropy in a text box and then passes values to Sql server store Procedures then it will give following error: Error Type: Microsoft OLE DB Provider for SQL Server (0x80040E14) Line 1: Incorrect syntax near 's'. my calling store procedure syntax is: rsinsert_products.Open "exec sp_insert_products '"&vPdescription&"',dbc, adOpenDynamic ,adLockOptimistic . Where vPdescription contains kamran's home. Please tell me how i'm gonna put "'" in database from above method. Thanx. Kamran Ahmed
I want to put HTML code in my ASP form and then input in to a database in SQL SERVER 7.0, but due to some syntax problems i can't be able to do it. Please tell me how i'm gonna input a typical HTML code in Database field. Thanx.
Hello everyone, I am new to mssql so please excuse all my silly questions.
I can create databases and tables. This is fairly easy, now I am having trouble with inputting data into the database using the data entry browser (or whatever it is called to enter data directly into a table).
I usually get an error when trying to submit the entry, firstly I have a "id" field which I think I have set to auto increase (Identity is ticked, seed and increment is set to 1).
when I go to add data all fields have "Null" in them and from what I understand it allows the fields to be empty, except the primary key which is the id field in this case and I expect that to be filled in automatically like with mysql but isn’t.
Can some kind person instruct or direct me somewhere on how to enter data into a table without it failing.
hi there.. I have write a code in the submit button using vb code so that when people key in their email.. it will be saved in my created database called test.mdf. but when i debug it, i tried to write an my email address in the textbox in my website but when i click at the submit button, the web page display the email was not enter in my database. here is the code, can anybody help me. i'm really lost here.. Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim TestDataSource As New SqlDataSource()TestDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("TestConnectionString1").ToString()
TestDataSource.InsertCommandType = SqlDataSourceCommandType.Text TestDataSource.InsertCommand = "INSERT INTO Email(EmailAddress, IPAddress, DateTimeStamp) VALUES (@EmailAddress,@IPAddress,@DateTimeStamp)" TestDataSource.InsertParameters.Add("EmailAddress", emailAddressTextBox.Text) TestDataSource.InsertParameters.Add("IPAddress", Request.UserHostAddress.ToString())TestDataSource.InsertParameters.Add("DateTimeStamp", DateTime.Now()) Dim rowsAffected As Integer = 0
Try rowsAffected = TestDataSource.Insert() Catch ex As Exception Server.Transfer("test_problem.aspx")
Finally
TestDataSource = Nothing
End Try
If rowsAffected <> 1 ThenServer.Transfer("test_problem.aspx") ElseServer.Transfer("Test_Confirm.aspx")
I tried matching the input username with the database. Although the input value is the same as the database, but it doesnt goes into the if statement to increase the "stat" value. Please advise what went wrong. Thanks.
protected void btnEnter_Click(object sender, EventArgs e) { if (txtUsername.Text.Length > 0) { status++; Label3.Text = ""; } else { Label3.Text = "Please enter a username"; }
if (txtPassword.Text.Length > 0) { status++; Label4.Text = ""; } else { Label4.Text = "Please enter a password"; }
if (status == 2) { int stat = 0; string mySelectQuery = "SELECT * FROM users";
SqlConnection myConnection = new SqlConnection("Data Source=WINSON-COMP;Initial Catalog=winson;Integrated Security=True");
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection); try { myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { stat = 0;
I have a problem selecting fields from a table where fields are equal to user input from a listbox. example listbox of zip codes: 33023[red]22300[/red]39844[red]29339[/red]23883[red]38228[/red] user wants to retreive highlight zip codes from database.connection working perfect.Thank you for your help.
I am building a pretty simple intranet application where we need to be able to track changes to tables. The tracking feature do not need to be very advanced, we just need to see who changed something and what it was. Therefore I decided just to use a trigger based solution, but need some input/advice since my SQL skills is somewhat lacking.
Consider the following (mock-up) schema:
-- My content table CREATE TABLE [Content]( [ContentGuid] [uniqueidentifier] NOT NULL PRIMARY KEY DEFAULT (newid()), [Data] [nvarchar](4000) NOT NULL, [ChangedBy] [nchar](10) NOT NULL, [MaybeNull] [int] NULL )
-- My history table CREATE TABLE [History]( [ChangedTable] [nvarchar](50) NOT NULL, [ReferenceGuid] [uniqueidentifier] NOT NULL, [ChangedBy] [nchar](10) NOT NULL, [ChangedOn] [datetime] NOT NULL DEFAULT (getutcdate()), [IsDelete] [bit] NOT NULL DEFAULT ((0)), [Changes] [xml] NOT NULL ) ON [PRIMARY]
-- My insert/update trigger CREATE TRIGGER [RecordChangeOnInsertUpdate] ON [Content] AFTER INSERT,UPDATE AS BEGIN SET NOCOUNT ON;
DECLARE @Changes xml SET @Changes = (select * from [inserted] for xml raw ('Content'), elements xsinil)
INSERT INTO [History] ([ChangedTable] ,[ReferenceGuid] ,[ChangedBy] ,[ChangedOn] ,[IsDelete] ,[Changes]) SELECT 'Content', ContentGuid, ChangedBy, getutcdate(), 0, @Changes FROM [inserted] END
-- My delete trigger CREATE TRIGGER [RecordChangeOnDelete] ON [Content] AFTER DELETE AS BEGIN SET NOCOUNT ON;
DECLARE @Changes xml SET @Changes = (select * from [deleted] for xml raw ('Content'), elements xsinil)
INSERT INTO [History] ([ChangedTable] ,[ReferenceGuid] ,[ChangedBy] ,[ChangedOn] ,[IsDelete] ,[Changes]) SELECT 'Content', ContentGuid, ChangedBy, getutcdate(), 1, @Changes FROM [deleted] END
I have decided to use the "one history table for all table changes" method. The changes for a row is stored in a xml column which obviously limits the total size of columns in a table being tracked, but that is not a problem in my application. In general I like this set up, since I will be able to change the schema continuously without having to change the triggers, and since the application will probably evolve a lot over the coming months this is pretty important to me.
EDIT: I should add that all the tables I will be tracking have a uniqueidentifier column. This makes it possible to related table rows in the different tables being tracked with their history.
A few concerns with the above SQL:
- Can the inserted/deleted table change between "SET @Changes = (select * ..." and the "INSERT INTO ..." statement, such that the data is not valid? If so, how to work around that?
- If I were to (hypothetically) perform a "UPDATE [Content] SET [Data] = 'something'", not only is my update trigger called once for each row updated, but the XML added to the inserted row in the history table ([History].[Changes]) represent all the rows updated in the batch update. How do I get around this?
I am a very beginner in SQL and know a little bit VB.
I created a database table with two columns, one for key and the other for data. I'd like to update the data column using excel sheet which contains the same columns, key and data.
WHERE (dbo.document.docVisible = 'yes') AND (dbo.document.docHide = 'NO') AND (dbo.t_files.fileMoved = '1') AND (dbo.documentCategory.docCategoryName LIKE '%olic%') AND (dbo.minisite.sectionLive = 1) AND (dbo.t_files.fileName <> N'A LINK') AND (dbo.t_files.fileName NOT IN (SELECT exFileID FROM t_exclude)) OR (dbo.document.docVisible = 'yes') AND (dbo.document.docHide = 'NO') AND (dbo.t_files.fileMoved = '1') AND (dbo.minisite.sectionLive = 1) AND (dbo.t_files.fileName <> N'A LINK') AND (dbo.t_files.fileName NOT IN (SELECT exFileID FROM t_exclude)) AND (dbo.document.docDesc LIKE '%olic%') OR(dbo.document.docVisible = 'yes') AND (dbo.document.docHide = 'NO') AND (dbo.t_files.fileMoved = '1') AND (dbo.minisite.sectionLive = 1) AND (dbo.t_files.fileName <> N'A LINK') AND (dbo.t_files.fileName NOT IN (SELECT exFileID FROM t_exclude)) AND (dbo.document.docType BETWEEN 1 AND 4) OR (dbo.document.docVisible = 'yes') AND (dbo.document.docHide = 'NO') AND (dbo.t_files.fileMoved = '1') AND (dbo.minisite.sectionLive = 1) AND (dbo.t_files.fileName <> N'A LINK') AND (dbo.t_files.fileName NOT IN (SELECT exFileID FROM t_exclude)) OR(dbo.t_files.fileName IN ('127-2006-1-27-3321130.pdf', '127-2006-1-30-3726619.pdf', '127-2006-1-27-5700042.pdf', '127-2006-1-27-5678586.pdf', '127-2006-1-27-5693574.pdf', '127-2006-1-27-5873392.pdf')) ORDER BY dbo.document.docDesc
Right - as you can see, some of the line slook pretty similar. When I try and do:
(one AND two AND three) AND (four OR five), I get
(one AND two AND three AND four) OR (one AND two AND three AND five)
when using enterprise manager. Is there anyway to keep the first way of doing it. Otherwise, everytime I add anotehr OR statement in, I'll have to create a new line!
I had received a message that my log file is full and it do not enable to me to do a database backup before free up disk space. How do i clean up de log file (_log.ldf)?
I have the following query which strips out middle initial data from the first_name column and populate the middle_initial column with the relevant data.
What my query does not handle is when a first name has a single character (IE: A). In its current state, the "A" would be moved to the middle_initial field with a period added to the end (IE A.). The first_name column would also include "A". Basically, when a single character first name is found in the first_name column, I do not want to populate the middle_name field.
Hope this does not sound too cryptic; query is below along with some sample data when run.
SELECT first_name, CASE WHEN SUBSTRING(LTRIM(RTRIM(first_name)),LEN(LTRIM(RTRIM(first_name)))-1,1)=' ' THEN SUBSTRING(LTRIM(RTRIM(first_name)),LEN(LTRIM(RTRIM(first_name))),1) +'.' ELSE NULL END AS 'middle_initial', CASE WHEN SUBSTRING(LTRIM(RTRIM(first_name)),LEN(LTRIM(RTRIM(first_name)))-1,1)=' ' THEN LEFT(LTRIM(RTRIM(first_name)),CASE WHEN LEN(LTRIM(RTRIM(first_name)))>=2 THEN LEN(LTRIM(RTRIM(first_name)))-2 ELSE LEN(LTRIM(RTRIM(first_name))) END) ELSE LTRIM(RTRIM(first_name)) END AS 'first_name_removing_initials' FROM contact
Sample Data first_name, middle_initial, first_name_removing_initials, Paul, NULL, Paul A, A., A, A Fred, NULL, A Fred, Aaron, NULL, Aaron
I have a db server that had served both my application data and reporting services. I have since installed a second db server to be the reporting services server; the primary box still stores the application data. I am keeping reporting services installed and set up on the primary box, since I would like it to act as a warm standby for the reporting services function.
However, the ReportServerTempDB on my primary box is still quite large. The ChunkData table is quite close to 10 gig. The CleanupCycleMinutes property is set to the default of 10. Clearly any data that might be in this table is far older than that.
Is there some recommended method of clearing this data? Can I just delete the rows or do a truncate on the table? I would prefer not to uninstall/reinstall reporting services, as this machine is actively serving my application data.
To allow users enter chinese character into table, I did try to change the field type to nchar and this is workable. But I have few hundred tables.. Is there anyway to change the setting in easier way? by instead change the field type one by one for each table?
I tried change the collation to Chinese_PRC_90_BIN for the database, but it is not support chinese input..
The Above is my database, I need help in retrieving the X_Co and the Y_Co using values of rcv_A, rcv_B and rcv_C to compare with the Mean_A, Mean_B, Mean_C. The values of rcv_A, rcv_B and rcv_C are instances of values that are not exact of the mean columns , and we want is to compare it against our database and retrieve the row that is the closest to the rcv_A, rcv_B and rcv_C.
Here is an example of what i need. Let's say my rcv_A = 71, rcv_B = 73 and rcv_C = 70.8, so the row with mean value closest would be row 1, followed by row 2, then row 3.
So the result i hope to retrieve is in order of the closest value and i only need the X_Co and Y_Co. This is what i want
Hi, I need some advise in the log shipping. The log files in the primary server get cleaned up according to what I have specified in the maintenance plan. But the log files that got shipped to the secondary server stay there for ever wasting my hard disc. Will it make any problem if I remove them or can I set it up to remove all files earlier than past 2 hrs? Please advise. Thanks
My problem is that I cannot completely clean buffer cache on SQL Server 2005 version 9.00.2047.00 (probably SP1).
Right after I run DBCC DROPCLEANBUFFERS in the context of my database (this is development server, and so far I am only the one who is working with a particular database), I run a script that quetries sys.dm_os_buffer_descriptors view also from the context of my database to make sure that the buffer cache is really clean. However it shows large number of entries totalling 42 MB.
I ran both DBCC an the script in the past too, and it always showed nothing in the results, that means that buffers were really clean. The reason why I am running this is for benchmarking of existing and new application.
Does anybody have any idea, suggestions, how to troubleshoot this issue ? I already closed all connections to this database, but rebooting the server is not an option since other people are also working on it.
I have a custom Data Flow task that creates temp files to the system temp directory during processing. A lot of times, we'll use SSIS to do one data transformation, running and tweaking the package along the way... we do this in the designer ... if we notice something that's incorrect in the data view, we just hit the stop button and fix it. However, when we do this, the Cleanup() function isn't called, and my temp files are left in the temp directory, when they really ought to be disposed of.
Is there a method that gets called every time when the DtsDebugHost quits, whether it finished, didn't finish properly, or was stopped in the middle? What would be a good way (other than having some service that monitors what temp files are used by what processes) to clean up temp files after we don't need them?
I am importing Visual FoxPro (6) views into SQL 2000 tables and I am looking for a snippet of code to "clean up" date fields upon insertion. I can insert the views into the SQL tables fine using the tables/views selection of DTS as my source. However, I would like to ensure the date fields are in fact vaild dates and not garbage using the SQL query option of DTS source. I would like to do the insert and cleanup in one step. Do you have a snippet of code to validate a date field that I can use? Thank you for any assistance in advance, Terry.