Get Info From Database With Dropdownlist
Dec 19, 2003How do you get info from an SQL database to be displayed on a dropdownlist?
View 2 RepliesHow do you get info from an SQL database to be displayed on a dropdownlist?
View 2 RepliesHi all.
I have a huge problem that ive been sitting with for awhile.
I have a web page with 4 dropdownlist boxes on it
Gender:
Race:
Field:
Location:
Now a user can search a SQL db from selecting values from these 4 dropdownlist boxes which are equal to values in the db obviously.
when they have done that and pressed submit a Gridview is populated with the people corresponding details and the user is able to view each row seperately.
Now the problem i am having is that when i havent used all 4 selections for eg
Gender: null (no value selected)
Race: Black
Field: Accounting
Location: Los Angeles
then no information is returned from the db in the gridview.
im using a sqldatasource to populate the gridview and here is the query string that i am using :
Code:
sql
SELECT [title], [gender], [initials], [name], [surname], [birthdate], [postaladdress], [suburb], [city], [zipcode], [criminalrecord], [drivers], [maritalstatus], [dependants], [citizenship], [province], [contactref], [hometel], [cell], [jobtitle], [relocate], [emmigrate], [email], [worktel], [enddate], [startdate], [FIELD], [education], [company], [positionheld], [jobdescription], [contactperson], [contacttel], [startdate2], [contactperson3], [jobdescription3], [positionheld3], [company3], [enddate3], [startdate3], [contacttel3], [other] FROM [cvinformation] WHERE (([race] = CASE WHEN @race IS NOT NULL THEN @race ELSE [race] END) AND ([province] = CASE WHEN @province IS NOT NULL THEN @province ELSE [province] END) AND ([education] = CASE WHEN @education IS NOT NULL THEN @education ELSE [education] END))
what i want to do is whether the user doesnt choose any selection and leaves the choice null that ALL the information in the table of the db be shown and even if they only choose 2 values and leave the others null then it still brings back the information from the criteria chosen..
Is this possible.?
Hey I just wanted to know if anyone could tell me how to bind values from a database to a dropdownlist?
View 2 Replies View Relatedhello..i need your help to provide me the idea and code how to view the data from database based on search criteria from user's input?the user's may fill up textbox and choose a criteria from dropdownlist...i am so no idea how to code it since i am fairly new in asp.net
i have 2 dropdownlist which is ddlCategory and ddlItem.i want<<< a)both ddl get data from sql db.b)view the data in gridview. i need code in vb.net to retrieve and post.tq
View 1 Replies View RelatedHello,
I'm attempting to generate a dropdownlist by binding it to a database table. My screen has a view of the records plus a footer for inserting new records. I want to populate a drop down list of items from the database on both FooterTemplate and EditItemTemplate. I can successfully create the list on FooterTemplate (the insert new record fields). Here, I have no problems with my database connections.
On page load, if I hit 'Edit', it gives me this error:
There is already an open DataReader associated with this Connection which must be closed first.
I tried closing the datareader and I get an error: Invalid attempt to Read when reader is closed.
Here's the snippet of code:
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
LoadDataFromDB()
If Not IsPostBack Then
DataBindGrid()
End If
End Sub
Sub LoadDataFromDB()
Dim strSQLStmnt As String
Dim cmdDefaults As SqlCommand
' Create new command object passing it our SQL query
' and telling it which connection to use.
strSQLStmnt = "SELECT tblTemplates.TemplateID, tblTemplates.Description, " _
& "tblTemplates.Tuition, tblTemplates.Books, tblTemplates.TrainingTable, tblTemplates.Housing, " _
& "tblResidency.ResidencyType, tblCategory.Type, tblCategory.Description AS CategoryDesc, " _
& "tblScholarship.ScholarshipType FROM tblTemplates INNER JOIN tblResidency ON tblTemplates.ResidencyID = " _
& "tblResidency.ResidencyID INNER JOIN tblScholarship ON tblTemplates.ScholarshipID = tblScholarship.ScholarshipID " _
& "INNER JOIN tblCategory ON tblTemplates.CategoryID = tblCategory.CategoryID"
cmdDefaults = New SqlCommand(strSQLStmnt, conDefaults)
' Open the connection, execute the command, and close the connection.
conDefaults.Open()
rdrDefaults = cmdDefaults.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
DefaultsDataGrid.ShowFooter = True
End Sub
Sub DataBindGrid()
DefaultsDataGrid.DataSource = rdrDefaults
DefaultsDataGrid.DataBind()
End Sub
Function BindResidency() As DataSet
'Populate the ddlDataSet
Const strSQLDDL As String = _
"SELECT Distinct ResidencyID, ResidencyType FROM tblResidency"
Dim myDataAdapter As SqlDataAdapter = New _
SqlDataAdapter(strSQLDDL, conDefaults)
myDataAdapter.Fill(ddlDataSet)
Return ddlDataSet
End Function
And the asp.net:
<asp:TemplateColumn HeaderText="Residency"> <ItemTemplate> <%# Container.DataItem("ResidencyType") %> </ItemTemplate> <FooterTemplate> <asp:DropDownList id="add_residency" runat="server" Width="178px" DataSource="<%# BindResidency() %>" DataTextField="ResidencyType" DataValueField="ResidencyID"> </asp:DropDownList> </FooterTemplate> <EditItemTemplate> <asp:DropDownList id="edit_residency" runat="server" Width="178px" DataSource="<%# BindResidency() %>" DataTextField="ResidencyType" DataValueField="ResidencyID"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn>
Any help would be appreciated!
Thanks,
Curtis
Hi all,
I am trying to write a web page connected to an sql database of my MP3 files. I have a dropdown list box that populates with the artist, this hopefully being used to filter results into a datagrid. However, i am having a problem with the ddlb box repopulating on post back, i trawled the news groups and coded the population of the ddlb within an "if not page.postback" statement but to no avail. If i connect the ddlb to another sql database i have, the page reloads with the selctedvalue retained. So the theory is now that it is the SQL database, (is this a limitation of SQL express?) and i am having troubleshooting this. Here is the SQL of the databse:
USE [mp3]GO/****** Object: Table [dbo].[Table_1] Script Date: 04/21/2008 20:40:21 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Table_1]([Title] [nvarchar](50) NOT NULL,[Artist] [nvarchar](50) NULL,[Album] [nvarchar](50) NULL,[Year] [nvarchar](25) NULL,[Comment] [nvarchar](500) NULL,[TrackNumber] [nvarchar](10) NULL,[path] [nvarchar](300) NOT NULL,[genre] [nvarchar](25) NULL,[id] [int] IDENTITY(1,1) NOT NULL,CONSTRAINT [PK_Table_1_1] PRIMARY KEY CLUSTERED ([id] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
Any help much appreciated.
Cheers
Billy
Hi,
I need to list in Word doc all the databases, tables and sp under a server. Is there a quick method of doing that?
Thanks
Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
I want to be able to see when records have been added to a table. The issue is we have a DTS job scheduled to run every night. The developer who wrote it password protected it and doesn't work here anymore. I want to add a step to this series of DTS jobs and want to run it just prior to his job. Is there a way to see when the records are being added or when this job is being run? Thanks again, you guys are the best.
ddave
The situation is I need info from a certain SharePoint site that is in a sql database. The problem is The SharePoint site currently contains data from 9 different projects, all using the same database. The database is a complex setup and it would not be an easy operation to extract the special information alone. The database is run with Microsoft SQL and is comprised of 4 separate databases. 3 databases organize the data (500+mb of data total) and 1 stores the data for all the sites (12.5+GB and increasing at a rate of 100-300mb per day).
How can I get the special data I need from this setup???
Please help
Hi there :)
I was hoping someone could help me figure out why this doesn't work....
I have a class called ProductsDB with a method called AddProduct that looks like this:
public String AddProduct(int categoryID, int makeID, string name, double price, double saleprice, double offerprice, int homepage, string thumbpath, string imagepath, string description)
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("ProductsAdd", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter parameterCategoryID = new SqlParameter("@CategoryID", SqlDbType.Int, 4);
parameterCategoryID.Value = categoryID;
myCommand.Parameters.Add(parameterCategoryID);
SqlParameter parameterMakeID = new SqlParameter("@MakeID", SqlDbType.Int, 4);
parameterMakeID.Value = makeID;
myCommand.Parameters.Add(parameterMakeID);
SqlParameter parameterName = new SqlParameter("@Name", SqlDbType.NVarChar, 50);
parameterName.Value = name;
myCommand.Parameters.Add(parameterName);
SqlParameter parameterPrice = new SqlParameter("@Price", SqlDbType.Money, 8);
parameterPrice.Value = price;
myCommand.Parameters.Add(parameterPrice);
SqlParameter parameterSalePrice = new SqlParameter("@SalePrice", SqlDbType.Money, 8);
parameterSalePrice.Value = saleprice;
myCommand.Parameters.Add(parameterSalePrice);
SqlParameter parameterOfferPrice = new SqlParameter("@OfferPrice", SqlDbType.Money, 8);
parameterOfferPrice.Value = offerprice;
myCommand.Parameters.Add(parameterOfferPrice);
SqlParameter parameterHomepage = new SqlParameter("@Homepage", SqlDbType.Bit, 1);
parameterHomepage.Value = homepage;
myCommand.Parameters.Add(parameterHomepage);
SqlParameter parameterThumbnail = new SqlParameter("@Thumbnail", SqlDbType.NVarChar, 50);
parameterThumbnail.Value = thumbpath;
myCommand.Parameters.Add(parameterThumbnail);
SqlParameter parameterImage = new SqlParameter("@Image", SqlDbType.NVarChar, 50);
parameterImage.Value = imagepath;
myCommand.Parameters.Add(parameterImage);
SqlParameter parameterProductID = new SqlParameter("@ProductID", SqlDbType.Int, 4);
parameterProductID.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(parameterProductID);
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
// Calculate the ProductID using Output Param from SPROC
int productId = (int)parameterProductID.Value;
return productId.ToString();
}
catch
{
return String.Empty;
}
}
And then in another cs file for my aspx page I have an event handler for an add button in a webform, which looks like this:
// Add New Product to ProductDB database
bikescene.Components.ProductsDB accountSystem = new bikescene.Components.ProductsDB();
String productId = accountSystem.AddProduct(Int32.Parse(DDLproductcategory.SelectedValue), Int32.Parse(DDLproductmanufacturer.SelectedValue), TBproductname.Text, Double.Parse(TBproductprice.Text), Double.Parse(TBproductsaleprice.Text), Double.Parse(TBproductofferprice.Text), Int32.Parse(DDLproducthomepage.SelectedValue), thumbnailpath, imagepath, TBproductdescription.Text);
And finally, here is my stored procedure:
CREATE Procedure ProductsAdd
(
@ProductID int,
@CategoryID int,
@MakeID int,
@Name nvarchar(50),
@Price money,
@SalePrice money,
@OfferPrice money,
@Homepage int,
@Thumbnail nvarchar(50),
@Image nvarchar(50),
@Description nvarchar(500)
)
AS
INSERT INTO Products
(
productID,
categoryID,
makeID,
name,
price,
saleprice,
offerprice,
homepage,
thumbpath,
imagepath,
description
)
VALUES
(
@ProductID,
@CategoryID,
@MakeID,
@Name,
@Price,
@SalePrice,
@OfferPrice,
@Homepage,
@Thumbnail,
@Image,
@Description
)
SELECT
@ProductID = @@Identity
GO
Basically, my images are uploaded to the server just fine but nothing is being added to the database + I don't get any error messages.
Any ideas?
Many thanks indeed :)
SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tab_db1'The above query will give the information of the table 'tab_db1' if it is available in the current database (say db1) connected.How can i access the information of a table (say 'tab_db2') which is created under a different database say db2 from the current db connected say db1.I tried the above query with changing the table_name to 'db2..tab_db2'but went invain.sysobjects also dint work..Any help on this will be appreciated..regards,Sathya V
View 2 Replies View RelatedI have a database that has a table with tons of data in it and it is getting close to the 999 days before it starts deleting the oldest records. Is there a way to allow the table to keep all of the information? I don't think there is, so here is my next question. Is there a way that I can move the entire table into another database to save all the information and start over with the 999 days? My main goal here is to not lose ANY information from any table from the database.
Also, I was thinking that when an entry is added into the main table, if it can also be added into the other table where I move the old data? I think a trigger can be used here, but I'm not sure how to do one in 2005. Thank you very much in advance for your help!!!
Database Mail only sends SMTP email messages and logs problemsconnecting to the mail server. However, I also need to log bouncedemails (bad address, etc).Are there any clean ways to do this with Database Mail and Exchange?Or will I have to mix Database Mail with SQL Mail to read bounces outof the inbox? Or, have a .NET windows service that talks to theExchange API?
View 1 Replies View RelatedI have a query that gets the tables, columns, indexes, index_columns for all tables in a data base.
But, I need to be able to select any data base on the server
and then drill down into the tables, columns, etc.
I looked at sys.databases but can't see how to relate that to the
sys.tables to extend my query.
Is there a way?
I've looked at the information_schema area and catalog views
but I don't see a solution yet.
Creating custom Register form That inserts user info in to database via storeprocgetting following errorCompilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'ValidateInput' is not a member of 'System.Web.UI.WebControls.TextBox'.
Source Error:
Line 3496: Me.__BuildControlTree(Me)
Line 3497: Me.AddWrappedFileDependencies(Global.ASP.partfrm_aspx.__fileDependencies)
Line 3498: Me.Request.ValidateInput
Line 3499: End Sub
Line 3500:
>.ASPX <asp:Wizard ID="AddParticipantWizard" OnFinishButtonClick="AddParticipant_FinishButtonClick" FinishDestinationPageUrl="~/partReg.aspx" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Register Participant">
<h3> Register: </h3>
<hr />
<table border="0">
<tr>
<td align="Left" colspan="2">
<h3>
PARTICIPANT INFORMATION: </h3><hr />
Please enter information for the attendee and click 'continue'.</td>
</tr></table>
<table border="0">
<tr>
<td align="right"> Registrant Information
</td>
<td style="width: 232px">
<asp:CheckBox ID="CheckBox1" runat="server" /> Register Me</td>
</tr>
<tr>
<td align="Left" colspan="2">
<table border="0">
<tr>
<td align="right">
<asp:Label ID="FirstNameLabel" runat="server" AssociatedControlID="firstname">First Name:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="firstname" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" ControlToValidate="firstname"
ErrorMessage="First Name is required." ToolTip="First Name is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="LastNameLabel" runat="server" AssociatedControlID="lastname">Last Name:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="lastname" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="LastNameRequired" runat="server" ControlToValidate="lastname"
ErrorMessage="Last Name is required." ToolTip="Last Name is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="Email" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr><td style="width: 232px"><br /></td></tr>
<tr>
<td align="right" style="height: 32px">
<asp:Label ID="StreetLabel" runat="server" AssociatedControlID="Street">Street:</asp:Label>
</td>
<td style="width: 232px; height: 32px">
<asp:TextBox ID="Street" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="StreetRequired" runat="server" ControlToValidate="Street"
ErrorMessage="Street is required." ToolTip="Street is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr><td></td>
<td> <br />
<br /> ".
</td></tr>
<tr>
<td align="right">
<asp:Label ID="CityLabel" runat="server" AssociatedControlID="City">City:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="City" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="CityRequired" runat="server" ControlToValidate="City"
ErrorMessage="City is required." ToolTip="City is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="StateLabel" runat="server" AssociatedControlID="State">State:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="State" runat="server" Width="18px">
</asp:TextBox><asp:RequiredFieldValidator ID="StateRequired" runat="server" ControlToValidate="State"
ErrorMessage="State is required." ToolTip="State is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr><td></td>
<td> <br /> <br /> </td></tr>
<tr><td style="width: 232px"><br /></td></tr>
<tr>
<td align="right">
<asp:Label ID="PostalCodeLabel" runat="server" AssociatedControlID="Zip">Postal/Zip<br />
Code:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="PostalCode" runat="server" Width="28px"></asp:TextBox>
<asp:RequiredFieldValidator ID="PostalCodeRequired" runat="server" ControlToValidate="PostalCode"
ErrorMessage="PostalCode is required." ToolTip="PostalCode is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="OrganizationLabel" runat="server" AssociatedControlID="Organization">Organization:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="Organization" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="OrganizationRequired" runat="server" ControlToValidate="Organization"
ErrorMessage="Organization is required." ToolTip="Organization is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="TitleLabel" runat="server" AssociatedControlID="Title">Title:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="Title" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="TitleRequired" runat="server" ControlToValidate="Title"
ErrorMessage="Title is required." ToolTip="Title is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="DepartmentLabel" runat="server" AssociatedControlID="Department">Department:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="Department" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="DepartmentRequired" runat="server" ControlToValidate="Department"
ErrorMessage="Department is required." ToolTip="Department is required." ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PhoneNumberLabel" runat="server" AssociatedControlID="Phone">Phone Number:</asp:Label>
</td>
<td style="width: 232px">
<asp:TextBox ID="Phone" runat="server" Width="195px"></asp:TextBox>
<asp:RequiredFieldValidator ID="PhoneRequired" runat="server" ControlToValidate="Phone"
ErrorMessage="Phone Number is required." ToolTip="Phone Number is required."
ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="RequestLabel" runat="server" AssociatedControlID="Request">Any special request:</asp:Label>
</td>
<td style="width: 232px">(e.g, )
</td>
</tr>
<tr>
<td align="right">
</td>
<td style="width: 232px">
<asp:TextBox ID="Request" runat="server" Width="235px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequestRequiredFieldValidator1" runat="server" ControlToValidate="Request"
ErrorMessage="Request is required." ToolTip="Request is required."
ValidationGroup="AddParticipantWizard">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:RegularExpressionValidator ID="EmailRegExp" runat="server" ControlToValidate="Email"
Display="Dynamic" ErrorMessage="The email format is invalid." ValidationExpression="S+@S+.S+"
ValidationGroup="AddParticipantWizard"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red">
<asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr><td></td>
<td align="right">
</td></tr>
</table>
</td>
</tr>
</table>
<asp:SqlDataSource ID="InsertPartDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" InsertCommand="PartInsert" InsertCommandType="StoredProcedure">
<InsertParameters>
<asp:ControlParameter ControlID="firstName" Name="firstName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="lastName" Name="lastName" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Email" Name="Email" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Street" Name="Street" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="City" Name="City" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="State" Name="State" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="PostalCode" Name="PostalCode" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Organization" Name="Organization" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Title" Name="Title" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Department" Name="Department" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Phone" Name="Phone" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="Request" Name="Request" PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="Assistance" Name="Assistance" PropertyName="SelectedValue"
Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Completion">
<p>
Your account has been successfully created.
</p>
<asp:Button ID="ContinueButton" runat="server" CommandName="Continue"
Text="Continue" />
</asp:WizardStep>
</WizardSteps>
</asp:Wizard> > CODE-BEHIND 'This event handler fires when the user clicks Finish. We need to insert the new participant record into the database
Protected Sub AddParticipant_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles AddParticipantWizard.FinishButtonClick
'Insert the Participant into the database
InsertPartDataSource.Insert()
'Send the user back to the homepage
Response.Redirect("~/PartReg.aspx")
End Sub
I use detach/attach method to move database to a new SQL Server 7 on MSCS. The security information was lost in the new server. Database Access permission was gone and I failed to select it again because message showed the database role is already exist. The default databases were also posted incorrectly. Would you please to tell me how to fix this type of peoblem or let me know how to move the login info such as login id, password, database permisson to the new server which locates in a different machine.
Thank you very much.
Rich
Hi, all,
I found that the SQL2000 EM does not show database space allcoated information, as well as tables and indexes size while SQL 7.0 does.
Someitmes these information are fairly handy.
is there any other easy ways to find out the same info from SQL2000
through Em, or elsewhere ??
Thanks
Anthony
I have seen a bunch of ways to get the size of all the tables within a database posted on this board. I decided to modify an older one I found here (http://www.sqlteam.com/item.asp?ItemID=282). I set it up so there is no cursors or temp tables. Pretty much just one select statement to return all the info you would need. It seems to be faster than anything I have seen so far. Take it for whats its worth. Thanks to the original creator.
/*
Original by: Bill Graziano (SQLTeam.com)
Modified by: Eric Stephani (www.mio.uwosh.edu/stephe40)
*/
declare @low int
select @low = low from
master.dbo.spt_values
where number = 1 and type = 'E'
select o.id, o.name, ro.rowcnt, (r.reserved * @low)/1024 as reserved,
(d.data * @low)/1024 as data, ((i.used-d.data) * @low)/1024 as indexp,
((r.reserved-d.data-(i.used-d.data)) * @low)/1024 as unused
from
sysobjects o
inner join
(select distinct id, rowcnt
from sysindexes
where keys is not null and first != 0) ro on o.id = ro.id
inner join
(select id, sum(reserved) reserved
from sysindexes
where indid in (0, 1, 255)
group by id) r on o.id = r.id
inner join
(select c.id, dpages+isnull(used, 0) data from
(select id, sum(dpages) dpages
from sysindexes
where indid < 2
group by id) c full outer join
(select id, isnull(sum(used), 0) used
from sysindexes
where indid = 255
group by id) t on c.id = t.id) d on r.id = d.id
inner join
(select id, sum(used) used
from sysindexes
where indid in (0, 1, 255)
group by id) i on d.id = i.id
where o.xtype = 'U'
order by reserved desc
Please help, i am really really struggling for a logic to handle 100's of reports we have via button click from asp.net webform.
in the button click i am constructing the url :
**************************************************************************************************************
http://localhost/reportserver?/MyReports/StatusReport&UserID=1&ContractID=1&subcode=null
*************************************************************************************************************
I have a table would like to maintain the parameters required for the chosen report:
when the user chooses from list box on the webform for StatusReport, immedeately it fetches the parameters related to Statusreport and gets everything which is stored with a space in between for each parameter, for this report i have 3 parameters:
UserID ContractID subcode
now how can i construct the string based on the above parameters , i am using vb.net as code behind for my webform(asp.net)
please any ideas will help me achieve the logic. please help thank you all very much.
I have a table with embedded files in it and also ftp server/user/pwd fields so that each record has all the data and information required and need to configure an SSIS package to to FTP them to the destination as specified in the record within the databaseAt the moment I have a data flow task which uses a Derived Column and an Export Column transformation which creates the files to a temp folder then it runs a ForEach loop container back on the control flow to FTP each file and to then move each file to an archive folder.
All I think I need to know how to do is to somehow control the FTP connection settings with the fields from the database within this foreach loop, but it is a for each file collection. I also need to update each record saying it has been FTP'd as well
Do I need to have an initial query outside of this foreach loop to populate an array which can be used for the 4 FTP connection fields (server/user/pwd/directory), if so how?
Any ideas as to how to correctly finish this package.
Thanks
I have a MySql Database i need to extract data from based on matching info in a local SQL Server database,
I will ultimately need to cycle through 20 of these MySql databases , but the query below is taking 1 minute and 20 plus seconds...Just for one..
Is there a simple tweak that would speed it up?
USE [CAS]
GO
DECLARE @PhoneDB varchar(max),
@SQL NVARCHAR(MAX);
set @PhoneDB = '[PHONEDB_PHI]';
set @SQL = 'SELECT
[Code]....
I have two database and both of them has the same table, i want to copy all info from this first table to the secornd table
For Example:
Database : DB_1, table is table_1
Database : DB_2, table is table_2
both table_1 and table_2 have the same struct
how can i insert all records from table_1 to table_2
thanks
Hello:I have add a DropDownList to my GridView and binded the dropdownlist to a field from a select statement in the SQLDataSource. I have EnabledEditing for my GridView. The GridView is populated with information from the select statement. Some of the information returned from the select statement is null. The field where the dropdownlist is binded it is null in some cases and does not have a value that is in the dropdownlist so I get and error when I attempt to do an update. 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value Is there a way to get around this besides initializing all the columns in the table that are going to be binded to a dropdownlist to a value in the dropdownlist?
View 1 Replies View Related
Hi,
I have sqldatasource that i set up in VS2005. i have a dropdownlist using this source. Data is added to the db from a different app and i want this dropdownlist to use the latest data on a page refresh.
However i can not refresh the sqldatasource - the dropdownlist does not show the latest additions to the db - i hae to rebuild to see them. i tried turnning 'enable caching' and 'enable viewstate' to false but no luck.
How is this done.
Thanks.
I'm using the GridView to display some accounting infromation. I have a project where I have a 14 character control number. I would like to have a dropdown list to select the account classification of records to be displayed. The accounting classification is the first two characters of the control number. So the dropdown list needs to show unique first two characters and the GridView will be filtered on these two characters. I have been trying to use "substring" in the ASP.NET code; not even sure you can.
Any suggestions on how to accomplish this would be greatly appreciated. See code below:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
DataTextField="control_num" DataValueField="control_num">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:GPCRReportsConnectionString %>"
SelectCommand="SELECT DISTINCT [substring(control_num,1,2)] FROM [Request]"></asp:SqlDataSource>
ERROR: Invalid column name 'substring(control_num,1,2)'.
Hi folks,
I'm in trouble getting an dropdownlist inserting its selected value into an .mdb
I'll insert my datasource code. There is another dropdownlist in this formview working good.
There is a datafield ID_Org_Einheit in the database to gather the value.
Could you please look this over?
Many thanks
Rosi
This is the dropdownlist
<asp:DropDownList ID="DDL_Org_alle" runat="server" DataSourceID="SDS_Org_alle" DataTextField="OE_gegliedert"
DataValueField="ID_org">
</asp:DropDownList>
and the datasource
<asp:SqlDataSource ID="SDS_insert_FB_log" runat="server" ConnectionString="<%$ ConnectionStrings:FahrtenbuchConnectionString %>"
InsertCommand="INSERT INTO tab_Fahrtenbuch_log([Datum_Eintragung], [Fahrer], [ID_Org_Einheit], [pol_Kennzeichen], [ID_Einsatzzweck], [Strecke_von], [Strecke_bis], [Zeit_von], [Zeit_bis], [km_von], [km_bis]) VALUES (@Datum_Eintragung,@Fahrer,@ID_Org_Einheit,@pol_Kennzeichen,@ID_Einsatzzweck,@Strecke_von,@Strecke_bis,@Zeit_von,@Zeit_bis,@km_von,@km_bis)" ProviderName="<%$ ConnectionStrings:FahrtenbuchConnectionString.ProviderName %>"
SelectCommand="SELECT Datum_Eintragung, Fahrer, ID_Einsatzzweck, Strecke_von, Strecke_bis, pol_Kennzeichen, ID_Org_Einheit, Zeit_von, Zeit_bis, Bemerkung, km_von, km_bis FROM tab_Fahrtenbuch_log">
<InsertParameters>
<asp:FormParameter FormField="Datum_EintragungTextBox" Name="Datum_Eintragung"/>
<asp:FormParameter FormField="FahrerEintragTextBox" Name="Fahrer"/>
<asp:FormParameter FormField="DDL_Org_alle" DefaultValue="1" Name="ID_Org_Einheit"/>
<asp:FormParameter FormField="polKennzTextBox" Name="pol_Kennzeichen"/>
<asp:FormParameter FormField="DDL_Einsatzzweck" DefaultValue="1" Name="ID_Einsatzzweck" Direction="Input" Size="3" /><asp:FormParameter FormField="StartTextBox" Name="Strecke_von"/> <asp:FormParameter FormField="ZielTextBox" Name="Strecke_bis"/>
<asp:FormParameter FormField="AbfahrtTextBox" Name="Zeit_von"/>
<asp:FormParameter FormField="AnkunftTextBox" Name="Zeit_bis"/><asp:FormParameter FormField="kmFahrtBeginnTextBox" Name="km_von"/> <asp:FormParameter FormField="kmFahrtEndeTextBox" Name="km_bis"/>
</InsertParameters></asp:SqlDataSource>
Need a little help! I am trying to insert ListItems values from a DropDownList into a database table. However in the code behind I am continuosly met with the error Name 'ddltest' is not declared. As you can see from the code below ddltest is an object with the ID ddltest. What am I doing wrong?
Protected Sub ddltest_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)Dim MyVar As String = ddltest.SelectedItem.Value
If MyVar = "" Then
ErrorMessage.Text = "Please select a test"
Else
'Insert selection into databaseDim oConnection As New SqlConnection
Dim oCommand As SqlCommand
Dim sConnString As String
Dim sSQL As String
sConnString = "Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|xxxxx.mdf;Integrated Security=True;User Instance=false"oConnection = New SqlConnection(sConnString)
sSQL = "INSERT INTO testDB(Myxxxx) Values (@Myxxxx)"
oConnection.Open()oCommand = New SqlCommand(sSQL, oConnection)oCommand.Parameters.Add(New SqlParameter("@Myxxxx", MyVar))
oCommand.ExecuteNonQuery()
oConnection.Close()
ErrorMessage.Text = "You selected " & MyVar & " and it has been added to the database."
End If
End Sub
<asp:TemplateField HeaderText="Test">
<EditItemTemplate>
<asp:DropDownList ID="ddltest" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddltest_SelectedIndexChanged" >
<asp:ListItem Selected="True" Value="" ><-- Please Select a test --></asp:ListItem><asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5" >5</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
hi,
how can i fill dropdownlist through code not through visit.and i need to know which is fastest and easy way for web application throught this below query.
cmd.Connection = conn
conn.Open()Dim ds As New DataSet
cmd.CommandText = "SELECT Emp_Name,Emp_ID FROM Employee "
da.Fill(ds, "data")
cmd.ExecuteNonQuery()
conn.Close()
hi ,
need your help please
I have got a dropdownlist which is getting it's items and values from the table with in SQL server , everything works fine.
I just want to be able to select default item , so when the page is loaded the dropdown list default will be that selected item.
as an exmple if the drop downlist items and values are as follow
item ----> value
---------------------
city -----> 1
tokyo -----> 2
london ------>3
these info is imported from the database
and I want by default tokyo to be selected
many thanks
M
----------------------------------------
here is my code:
Dim sqlConnection As SqlConnection
Dim sqlDataAdapter As SqlDataAdapter
Dim sqlCommand As SqlCommand
Dim dataSet As DataSet
Dim dataTable As DataTable
sqlConnection = New SqlConnection("user id=sa;password=testfirm;database=ken_live;server=csfirm03")
'pass the stored proc name and SqlConnection
sqlCommand = New SqlCommand("Select * From _aci",sqlConnection)
'instantiate SqlAdapter and DataSet
sqlDataAdapter = New SqlDataAdapter(sqlCommand)
dataSet = New DataSet()
'populate the DataSet
sqlDataAdapter.Fill(dataSet, "AA")
'apply sort to the DefaultView to sort by CompanyName
dataSet.Tables(0).DefaultView.Sort = "bsheet"
city.DataSource = dataSet.Tables("AA").DefaultView
city.DataTextField ="bsheet" ' what to display
city.DataValueField ="bsheet" ' what to set as value
city.DataBind()
Hi... im trying to insert whatever value a user selects from a drop down list box into a database.
So I have already stated that there are 5 different options (eg. 1,2,3,4,5) so I want it that when someone selects '2' and then clicks a button it inserts '2' into a db... I tried the following (DDL is the id of the drop down list box) :
Dim myCommand As SqlCommandDim objUsers As SqlTransactionDim strnumber As String = DDL.SelectedValueconnstring = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")conUsers = New SqlConnection(connstring)conUsers.Open()objUsers = conUsers.BeginTransaction
"INSERT INTO tblsomething (number) VALUES (strnumber)"
myCommand = New SqlCommand(strSQL, conUsers)myCommand.Transaction = objUsersmyCommand.ExecuteNonQuery()objUsers.Commit()conUsers.Close()
- Anyway suffice to say that this isnt working sssooooo...... help. Please
I've got the following code and it's not really what I want. With the below code I can select in a dropdownlist a value and in the other dropdownlist the correspondending value will be selected. But when I select a value the second dropdownlist won't be filled with all the data in the database. It is filled only with the correspondending value and not with the rest of the value. When someone changes his mind and want to select a value in the dropdownlist it can't be done. Any ideas??Default.aspx:<body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Botanische Naam: "> </asp:Label> <asp:DropDownList ID="DDL1" AutoPostBack="True" runat="server" OnSelectedIndexChanged="ChangeBotanicName" DataSourceID="SqlDataSource1" DataTextField="Botanische_Naam" DataValueField="Botanische_Naam"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BonsaiDataBaseConnectionString %>" SelectCommand="SELECT [Botanische Naam] AS Botanische_Naam FROM [BonsaiSoorten]"> </asp:SqlDataSource> <asp:sqldatasource id="SqlDataSource2" runat="server" connectionstring="<%$ ConnectionStrings:BonsaiDataBaseConnectionString%>" selectcommand="SELECT [Nederlandse Naam] AS Nederlandse_Naam FROM [BonsaiSoorten]WHERE [Botanische Naam] = @Title1"> <selectparameters> <asp:controlparameter name="Title1" controlid="DDL1" propertyname="SelectedValue" /> </selectparameters> </asp:sqldatasource> <asp:Label ID="Label2" runat="server">Nederlandse Naam:</asp:Label> <asp:DropDownList ID="DDL2" AutoPostBack="True" runat="server" OnSelectedIndexChanged="ChangeDutchName" DataSourceID="SqlDataSource3" DataTextField="Nederlandse_Naam" DataValueField="Nederlandse_Naam"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BonsaiDataBaseConnectionString %>" SelectCommand="SELECT [Nederlandse Naam] AS Nederlandse_Naam FROM [BonsaiSoorten]"> </asp:SqlDataSource> <asp:sqldatasource id="SqlDataSource4" runat="server" connectionstring="<%$ ConnectionStrings:BonsaiDataBaseConnectionString%>" selectcommand="SELECT [Botanische Naam] AS Botanische_Naam FROM [BonsaiSoorten]WHERE [Nederlandse Naam] = @Title2"> <selectparameters> <asp:controlparameter name="Title2" controlid="DDL2" propertyname="SelectedValue" /> </selectparameters> </asp:sqldatasource> </div> </form></body>Default.aspx.vb:Partial Class _Default Inherits System.Web.UI.Page Sub ChangeBotanicName(ByVal Sender As Object, ByVal e As System.EventArgs) DDL2.DataSourceID = "SqlDataSource2" End Sub Sub ChangeDutchName(ByVal Sender As Object, ByVal e As System.EventArgs) DDL1.DataSourceID = "SqlDataSource4" End SubEnd Class
P.S. I posted this before but can't find it anymore so here it is again
can someone please tell me if you can implement a drop down list within a table attribute.
If anyone could show me an example please do.
Kind Regards
Rob