Choose Default Value From DropDownList And SqlDataSource
Apr 15, 2006
Hello everyone
I'm really new to Data Presentation Controls and I already hate them couse I think they are way too complicated. Becouse of that i have already met wall many times. My last one sounds like this.
I'm triing to put a default value from, lets say SqlDataSource1 in a DropDownList that is created by SqlDataSource2. I know how to get value from SqlDataSource1 but I don't know how to use exactly that value as my default value in DropDownList.
Two more question.
1. Is it possible to have two different select statements in a SqlDataSource?
2. A SqlDataSource may contain an insert statement, select statement, update and delete. If I bind this SqlDataSource to a control how can I specify which of those statements will be used?
Thanks in advance
View 1 Replies
ADVERTISEMENT
Nov 8, 2006
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.
View 1 Replies
View Related
Feb 3, 2004
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()
View 15 Replies
View Related
Jan 9, 2007
i use asp.net 2.0 and c#
initially the dropdownlist control is bound to the queryA ("select * from tableA".) for sqldatasource1
now in a button click event, i want to change the query to queryB ("select * from tableA where id = @id".)
in the code below, i can change the SELECT query of sqldatasource1 from queryA to queryB, but how can i give value to the parameter? please help
protected void Button1_Click(object sender, EventArgs e)
{
sqldatasource1.SelectCommand = queryB
}
View 3 Replies
View Related
Oct 23, 2007
Hello,
I have specified a default database in my web.config like this:
<dataConfiguration defaultDatabase="scsLocal"/>
<connectionStrings> <add name="scsLocal" connectionString="server=DRLSWARTEBRV;database=SCS;uid=******;password=******;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Now I would like to configure a SQLDataSource control to use this default database, yet it prompts me for a connectionstring. I know I can program it in the code behind file (if I ommit connection string, it will use the default), but then I can make no use of the wizard for configuring the SQLDataSource which would safe me a lot of coding.
Is there a way to configure the SQLDataSource to use the default database that is specified in the web.config?
Thanks!
Veerle
View 1 Replies
View Related
Jan 21, 2007
I thought this would be easy. I have a repeater control and a sqldatasource control. I am trying to filter the select statement using DateTime.Now.ToString() and keep getting an invalid date string format. The control is on a content page in my asp.net site. On the master page this <%= DateTime.Now.ToLongDateString() %> works to display the current date. If I try and put <%= DateTime.Now.ToString() %> in the Default value of the SelectParameter it does not work. No intellisense either so I am assuming I am missing something. Here is the code... pretty basic really.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="sqlDSnews">
<ItemTemplate>
<h3><%# Eval("newTitle")%></h3>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource
ID="sqlDSnews"
runat="server"
ConnectionString="<%$ ConnectionStrings:XXXX%>"
SelectCommand="SELECT [newTitle], [newsDetails], [dateExpires], [newsImage], [dateCreated] FROM [News] WHERE (([GroupID] = @GroupID) AND ([dateExpires] >= @dateExpires))">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="0" Name="GroupID" QueryStringField="Gid" Type="Int32" />
<asp:Parameter Name="dateExpires" DefaultValue='<%= DateTime.Now.ToString() %> 'Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
** NOTE the DateTime does not show up in blue - if that helps with a solution **
View 5 Replies
View Related
Jul 7, 2007
Hi How do I set the default value of a SQLdatasource parameter to the current date-time <asp:Parameter Name="original_lastsaved" Type="DateTime" defaultvalue="???"/> The sql column field type is "datetime", so it will not accept a stringThanks for the help.Bones
View 3 Replies
View Related
Mar 18, 2008
While learning ASP.net 2.0, I was taught that the the default provider for the SqlDataSource was System.Data.SqlClient, and that I only needed to specify it as a provider when I put it in the web.config file. However, now (in VWDE 2008) when I add a SqlDataSource to a page, it adds ProviderName="System.Data.SqlClient". Does this mean that it isnt the default anymore?
View 1 Replies
View Related
Nov 24, 2006
If a sqldatasource is programed to send textbox1.text to a stored procedure, and the .text property is left empty, and there is no default value set for the parameter, what exactly is the stored procedure receiving?I would like to run a IF BEGIN statement on the value of the parameter in the stored procedure but the following does not work:IF @Parameter IS NULL BEGINor IF @Parameter = '' BEGINThe only way I've gotten it to work is if I set the default value of the parameter being sent to a specific alphanumeric value. Then do something like:IF @Parameter = '99' BEGIN<Code Here>END
View 4 Replies
View Related
Oct 18, 2006
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
Oct 26, 2007
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)'.
View 6 Replies
View Related
Jan 30, 2008
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>
View 3 Replies
View Related
Mar 3, 2008
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>
View 7 Replies
View Related
May 7, 2008
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()
View 4 Replies
View Related
Jan 16, 2006
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
View 3 Replies
View Related
Mar 23, 2006
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
View 3 Replies
View Related
Dec 11, 2007
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
View 11 Replies
View Related
Oct 24, 2007
I have a production server log shipping to a secondary server every 30 minutes (both SQL 2000), which the second server is used for both a warm standby server and for reporting from users. Issue: the log shipping locks the DB so reporting can't be done until the load is finished, the load to the second set of databases has taken up to 15 minutes to finish allowing the users only 15 minutes to run reports, this is not acceptable. The server also needs to be used for DR.
I am looking for another solution, I can't use Transactional Log shipping as not all of the tables in the databases have a primary key identified. So, I am looking for a real-time or near real-time reporting server that is more available to running reports and a warm standby server for Disaster recovery. I am trying to figure out what SQL Server 2000 has to provide (or even 2005 or 2008?) or I am also looking at some third party software, but not sure what is the best for a reasonable price.
Any help is appreciated.
Thanks....JB
View 8 Replies
View Related
Nov 11, 2006
Using asp.net 2.0 and visual studio 2005. The question is regarding the following ER diagram: I've made Firstname, lastname, buildingID and RoomNum all required fields. I've got a modified GridView that displays all of the table Faculty columns. It's been modified so the BuildingID and DepID are resolved to their actual field names and displayed in a DropDownList. In the dropdown list I used for inserting (a seperate DetailsView control), I manually inserted an item into the Department dropdownlist which had the text "-- Select a Department --" with a value of -1. MS SQL didn't like that -1 value so I wrote the following code to fix it: protected void dsFaculty_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
if (e.Command.Parameters["@DeptID"].Value.ToString() == "-1")
{
e.Command.Parameters["@DeptID"].Value = null;
}
} That means of course DeptID is null, which is ok. The problem arises is when I try to edit that row in the GridView. I get the an error 'ddlDepartment' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: valueIdeally, I'd like to make the dropdown list in the GridView show "-- None --" for the DeptID if it comes across a null value. I already tried playing around with the Command.Parameters in the dsFaculty_Selected function, but it didn't work. Ideas?
View 1 Replies
View Related
Jun 9, 2007
I am using Visual Studio 2005 & SQL Server. How do i implement a DDL for users to select which value to input. like i can with Access. i do not need a table i think. if not the table would have only ID & Value.?
View 2 Replies
View Related
Sep 24, 2007
How can I get two fields to appear side by side in the DropDownList? Ex. FName and LName
Thanks
View 1 Replies
View Related
Feb 12, 2008
My goal is to populate a dropdownlist with only with users that are "Techs". I am using the membership database that you ccan set up through VWD. I added this column to the aspnet_Users table: IsTech as bit datatype. I thought I had the right SQL statement but apparently not, because I get an Invalid column name 'True'.Here is my statement: <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:HRIServiceConnectionString1 %>" SelectCommand="SELECT [UserID], [FirstName]+ ' ' + [LastName] AS techid FROM [aspnet_Users] WHERE [isTech] = True ORDER BY [LastName], [FirstName]"> </asp:SqlDataSource>
View 9 Replies
View Related
Dec 19, 2003
How do you get info from an SQL database to be displayed on a dropdownlist?
View 2 Replies
View Related
Mar 25, 2006
I am using the createuserwizard, and have set up my own profile table which hold first name, last etc. In my CreateUserWizard, the field for Vendor is a dropdownlist that is to be populated from a list in a database. I set up the form without the createuserwizard, and everything went skippy, but when I placed it into the wizard, I now cannot access the control of the dropdownlist.
I have tried doing..
Using SqlConnection As New SqlConnection(WebConfigurationManager.ConnectionStrings("Personal").ConnectionString)Dim VendorID As DropDownListVendorID = CType(CreateUserWizard1.FindControl("VendorName"), DropDownList)
Dim MyReader As SqlDataReaderDim sel As String = String.Format("SELECT VendorID, Name FROM Vendors")Dim MyCommand As SqlCommandMyCommand = New SqlCommandMyCommand.CommandText = selMyCommand.CommandType = CommandType.TextMyCommand.Connection = SqlConnectionMyCommand.Connection.Open()MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection)But when I go to databind, it says:Object reference not set to an instance of an object. VendorID.DataSource = MyReaderLine 30: VendorID.DataValueField = "VendorID"Line 31: VendorID.DataTextField = "Name"
View 3 Replies
View Related
Mar 19, 2008
Hi 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.?
View 8 Replies
View Related
Nov 18, 2006
I have a listbox that lists countries....and if you choose a country, another listbox show cities in that country (fetched from a sql database)....And if you then chose a city in the second listbox, a dropdownlist will show restaurants in the city....(also fetched from a sql-database)...
Ok...I hope you understand...now to the problem....:
If you first chose a country, a city and a restaurant but then want to chose another country in the first listbox, the dropdownlist for the restaurants is still there filled with restaurants for the first country...I dont know how to "remove" the restaurants so that the dropdownlist is blank if someone switch country....
I think I need to do something in countryListbox_SelectedIndexChange....but I dont know what to write there....
I know that I can make the dropdownlist invisible by entering the following code:
sub countryListbox_SelectedIndexChange
dropdownlistRestaurants.visible = false
End sub
But I want it to be visible all the time!
Do you know what I could do?
View 1 Replies
View Related
Oct 4, 2007
In sql server reports.How to remove <select A Value> from the dropdownlist after deploying the report.
View 9 Replies
View Related
Feb 16, 2005
Hi All,
I have a dilemn:
On one side, I have a column C1 which could be a primary key because it is never null, the value is unique and identify the record. The problem is its a char type and its lenght can be close to 30.
Then, I've planned to add another column C2 of int type as PK. But then I need to add a unique constraint index on C1. Does it improve performance anyway?
Thanks
View 14 Replies
View Related
Jul 6, 2006
good day, everyone
if i have a transaction table with fields below :
transaction_no, product_id, product_desc, product_qty, product_txn, transaction_date
can some expert here point out to me , which is the best cluster-index and non-clsuter index ?
and possible kindly please explain why is it so? i'm not good in database so just explain like to beginner
thank you very much for guidance
View 3 Replies
View Related
May 6, 2008
(Hard to put a good subject on this one...)
I have a database containing a lot of users and these users can have four different kind of telephone numbers connected to them: "Direct phone", "Switchboard", "Cell phone", "Home phone". The phone numbers are stored in a separate table. Some users have 0 phone numbers, some have 1, some have 3 etc.
Now I have to transfer the data to another database with a strict table structure and here the table that contains the user also should contain the users phone number and an alternative phone number, if the user currently has more than one phone number connected.
This means that if for instance we have three or more phone numbers connected to one user, we can maximum transfer two of them. This is not a big issue though...
We have ranked the importance of the phone numbers in the order as I presented them above.
What I do in my T-SQL query is to do a ISNULL() and see if the user has "Direct phone" connected, if not I check for the next type and so on.
Now to my problem! Can anyone give me a suggestion of how to write the code for the extraction of the Alternative phone? What I need to do is to check if there is a "Direct phone" connected to the user, if so I should NOT chose that but the next phone number that I find.
View 7 Replies
View Related
May 14, 2008
I'm currently developing an ASP.NET website which is using SQL Server 2005 and I couldn't decide between two table designs and I hope you can give me your opinions
The website is for a school and it'll be used to create tests from questions. The teacher will:
1. Select grade (could be multiple selection)
2. Select class
3. Select subject
The thing is that same question could be used for multiple grades.
Example query: "Get me questions of trigonometry of math from grades 7,8,9"
(Names used instead of ID's to make it more clear)
The first design:
[BigRelationsTable]
ID - QuestionID - GradeID - ClassID - SubjectID
1 - Question123 - Grade7 - Math - Trig
2 - Question123 - Grade8 - Math - Trig
3 - Question123 - Grade9 - Math - Trig
This is a simple design but all of the columns will need indexes because all of them will be used for searching and that makes me think about table performance.
Second design:
[GradeClassRelations]
ID - Grade - Class
1 - 7 - Math
2 - 8 - Math
3 - 9 - Math
[ClassSubjectRelations]
ID - GradeClassRelationsID - SubjectID
1 - GradeClassRelations1 - Trig
2 - GradeClassRelations2 - Trig
3 - GradeClassRelations3 - Trig
[SubjectQuestionRelations]
ID - ClassSubjectRelationsID - QuestionID
1 - ClassSubjectRelations1 - 1
2 - ClassSubjectRelations2 - 1
3 - ClassSubjectRelations3 - 1
This one is more normalised but this time the need of doing multiple joins makes me wonder.
What do you think? Which one should I use? Or if you have any other suggestions I'm all ears
View 2 Replies
View Related
Dec 18, 2006
hi guys,
I have 4 columns and 3 rows. Columns are Name, Age, Gender and Weight. I have values entered for each column. I need to pick the highest value of weight if Name, Age, Gender are same and put that into new table. how can i do that?
View 6 Replies
View Related
Jun 7, 2006
Greetings SSIS friends
I want to implement the following query using SSIS Data flow Source component :
SELECT * FROM someTable WHERE someColumn = 'H'
How do I restrict the data coming from my data source? By that I mean how do I apply the WHERE clause in SSIS?! Should I use a conditional Split component?! but that would mean retrieving all records first then adding the split component (not the most efficient method surely).
Any suggestions would be much appreciated.
View 6 Replies
View Related