Sending Multiple Values From A ListBox To ControlParameter
Any ideas on how I can send multiple values from a listbox to a stored procedure? right now I have a ListBox Control called lbCategory, and I want to pass multiple selected items to a stored procedure.
<asp:SqlDataSource ID="dsFS" runat="server" ConnectionString="someConnectionString" SelectCommand="usp_FS" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="lbCategory" DefaultValue="%" Name="category" PropertyName="SelectedValue" type="String" />
</SelectParameters>
</asp:SqlDataSource>
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
How To Save Listbox Multiple Select Values
Hi, I have an ASP.NET form that stores it's data in MSDE but I just added a multi-select ListBox to the form and I'm having a hard time coming up with a way of writing that data to the database. Should I write the values into a column on the same table where I store the rest of the data from the form (values separated by a comma) or shouild I create another table (one to many) and store the data there. I like the second option, but I'm not sure how to loop through each value and write it to the database table. I grab the values for the selection as follow: foreach (ListItem lstItem in lbAttendees.Items) { if (lstItem.Selected == true) { grpList.Add(lstItem.Value.ToString()); } } but I'm not sure on what to do next and could use some help. Thanks Germano
View Replies !
View Related
Why Wont This Multiple Selection Listbox Insert Values Into Db
Hi, im a newbie. using VB.net / visual studio 2005 and SQL express I have pasted my page code below Basically i have a lisbox which is bound to an sqldatasource. It allows the user to select multiple names. I then have another datasource which when the page is submitted it posts various values from different fields into my db. The insert works fine.My problem is that the multiple selection wont allow me to insert into my db, it just captures the first value.I used this sub below to prove that when i click a button on my page it takes all my selected choices and puts them inside a text box, this works i can see them all. I then bound the textbox text value to the one im inserting into the db, however once again its only inserting the first value from the text box, how is this possible, the text box shows all the values and its set to string, it should insert everything in the text box Protected Sub selectedContact_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim alternatives As ListBox = CType(UploadPictureUI.FindControl("alternatives"), ListBox) Dim TextBox1 As TextBox = CType(UploadPictureUI.FindControl("TextBox1"), TextBox) For intLoopIndex As Integer = 0 To alternatives.Items.Count - 1 If alternatives.Items(intLoopIndex).Selected Then TextBox1.Text &= alternatives.Items(intLoopIndex).Text & _ ControlChars.CrLf End If Next End Sub Here is my full page code 1 <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Create Profile" Debug="true" %> 2 <script runat="server"> 3 Protected Sub UploadPictureUI_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles UploadPictureUI.ItemInserting 4 'Reference the FileUpload control 5 Dim UploadedFile As FileUpload = CType(UploadPictureUI.FindControl("UploadedFile"), FileUpload) 6 7 'Make sure a file has been successfully uploaded 8 If UploadedFile.PostedFile Is Nothing OrElse String.IsNullOrEmpty(UploadedFile.PostedFile.FileName) OrElse UploadedFile.PostedFile.InputStream Is Nothing Then 9 ShowErrorMessage("No file was uploaded. Please make sure that you've selected a file to upload.") 10 e.Cancel = True 11 Exit Sub 12 End If 13 14 'Make sure we are dealing with a JPG or GIF file 15 Dim extension As String = Path.GetExtension(UploadedFile.PostedFile.FileName).ToLower() 16 Dim MIMEType As String = Nothing 17 18 Select Case extension 19 Case ".gif" 20 MIMEType = "image/gif" 21 Case ".jpg", ".jpeg", ".jpe" 22 MIMEType = "image/jpeg" 23 Case ".png" 24 MIMEType = "image/png" 25 26 Case Else 27 'Invalid file type uploaded 28 ShowErrorMessage("Only GIF, JPG, and PNG files can be uploaded.") 29 e.Cancel = True 30 Exit Sub 31 End Select 32 33 'Specify the values for the MIMEType and ImageData parameters 34 e.Values("MIMEType") = MIMEType 35 36 'Load FileUpload's InputStream into Byte array 37 Dim imageBytes(UploadedFile.PostedFile.InputStream.Length) As Byte 38 UploadedFile.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length) 39 e.Values("imageData") = imageBytes 40 End Sub 41 42 Private Sub ShowErrorMessage(ByVal msg As String) 43 ErrorMessage.Text = msg 44 ErrorMessage.Visible = True 45 End Sub 46 47 Protected Sub UploadPictureUI_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles UploadPictureUI.ItemInserted 48 'If item successfully inserted, send user back to default 49 If e.Exception Is Nothing Then 50 Response.Redirect("~/confirmation.aspx") 51 End If 52 End Sub 53 54 Protected Sub selectedContact_Click(ByVal sender As Object, ByVal e As System.EventArgs) 55 Dim alternatives As ListBox = CType(UploadPictureUI.FindControl("alternatives"), ListBox) 56 Dim TextBox1 As TextBox = CType(UploadPictureUI.FindControl("TextBox1"), TextBox) 57 For intLoopIndex As Integer = 0 To alternatives.Items.Count - 1 58 If alternatives.Items(intLoopIndex).Selected Then 59 TextBox1.Text &= alternatives.Items(intLoopIndex).Text & _ 60 ControlChars.CrLf 61 End If 62 Next 63 End Sub 64 65 66 </script> 67 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 68 <table border="0" cellpadding="0" cellspacing="0" style="vertical-align: middle; 69 width: 795px; text-align: center"> 70 <tr> 71 <td align="center" style="height: 650px" valign="middle"> 72 <asp:DetailsView ID="UploadPictureUI" runat="server" AutoGenerateRows="False" CssClass="createProfile" 73 DataKeyNames="id" DataSourceID="accessProfiles" GridLines="None" DefaultMode="Insert"> 74 <Fields> 75 <asp:TemplateField HeaderText="Create Profile"> 76 <InsertItemTemplate> 77 <table style="width: 350px"> 78 <tr> 79 <td align="center" style="width: 150px; height: 30px"> 80 Name:</td> 81 <td align="center" style="width: 200px; height: 30px"> 82 <asp:TextBox ID="Nametxtbx" runat="server" CssClass="textboxstyle" Text='<%# Bind("Name") %>' MaxLength="20"></asp:TextBox> 83 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Nametxtbx" 84 CssClass="errorMessage" ErrorMessage="First Name is Required" ForeColor="">*</asp:RequiredFieldValidator></td> 85 </tr> 86 <tr> 87 <td align="center" style="width: 150px; height: 30px"> 88 Email:</td> 89 <td align="center" style="width: 200px; height: 30px"> 90 <asp:TextBox ID="emailtxtbx" runat="server" CssClass="textboxstyle" Text='<%# Bind("email") %>'></asp:TextBox> 91 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="emailtxtbx" 92 CssClass="errorMessage" ErrorMessage="Email Address is Required" ForeColor="">*</asp:RequiredFieldValidator> 93 <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="emailtxtbx" 94 ErrorMessage="RegularExpressionValidator" ForeColor="" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*">*</asp:RegularExpressionValidator></td> 95 </tr> 96 <tr> 97 <td align="center" style="width: 150px; height: 30px"> 98 Mobile:</td> 99 <td align="center" style="width: 200px; height: 30px"> 100 <asp:TextBox ID="mobiletxtbx" runat="server" CssClass="textboxstyle" Text='<%# Bind("mobile") %>' MaxLength="11"></asp:TextBox> 101 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="mobiletxtbx" 102 CssClass="errorMessage" ErrorMessage="Mobile Number is Required" ForeColor="">*</asp:RequiredFieldValidator> 103 </td> 104 </tr> 105 <tr> 106 <td align="center" style="width: 150px; height: 30px"> 107 Extension:</td> 108 <td align="center" style="width: 200px; height: 30px"> 109 <asp:TextBox ID="extensiontxtbox" runat="server" CssClass="textboxstyle" Text='<%# Bind("extension") %>' MaxLength="11"></asp:TextBox> 110 <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="extensiontxtbox" 111 CssClass="errorMessage" ErrorMessage="Phone Extension is Required" ForeColor="">*</asp:RequiredFieldValidator></td> 112 </tr> 113 <tr> 114 <td align="center" style="width: 150px; height: 30px"> 115 Alternative Contact:</td> 116 <td align="center" style="width: 200px; height: 30px"> 117 <asp:ListBox ID="alternatives" runat="server" CssClass="listboxstyle" 118 DataSourceID="getAlternatives" DataTextField="Name" DataValueField="Name" SelectedValue='<%# Bind("alternativeContact") %>' 119 SelectionMode="Multiple"></asp:ListBox> 120 <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="alternatives" 121 CssClass="errorMessage" ErrorMessage="Alternative Contact is Required" ForeColor="">*</asp:RequiredFieldValidator></td> 122 </tr> 123 <tr> 124 <td align="center" style="width: 150px; height: 30px"> 125 Job Role:</td> 126 <td align="center" style="width: 200px; height: 30px"> 127 <asp:DropDownList ID="DropDownList2" runat="server" CssClass="dropdownliststyle" DataSourceID="accessrole" 128 DataTextField="role" DataValueField="roleID" AppendDataBoundItems="True" SelectedValue='<%# Bind("roleID") %>'> 129 <asp:ListItem Value="" Selected="False">- Please Select -</asp:ListItem> 130 </asp:DropDownList> 131 <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="DropDownList1" 132 CssClass="errorMessage" ErrorMessage="Job Role is Required" ForeColor="">*</asp:RequiredFieldValidator></td> 133 </tr> 134 <tr> 135 <td align="center" style="width: 150px; height: 30px"> 136 Responsibilities:</td> 137 <td align="center" style="width: 200px; height: 30px"> 138 <asp:TextBox ID="resposibilities" runat="server" CssClass="textareastyle" Text='<%# Bind("responsibilities") %>' 139 TextMode="MultiLine" MaxLength="200"></asp:TextBox> 140 <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="resposibilities" 141 CssClass="errorMessage" ErrorMessage="Role Responsibilities are Required" ForeColor="">*</asp:RequiredFieldValidator></td> 142 </tr> 143 <tr> 144 <td align="center" style="width: 150px; height: 29px"> 145 Hobbies:</td> 146 <td align="center" style="width: 200px; height: 29px"> 147 <asp:TextBox ID="hobbiestxtbx" runat="server" CssClass="textareastyle" Text='<%# Bind("hobbies") %>' 148 TextMode="MultiLine" MaxLength="200"></asp:TextBox></td> 149 </tr> 150 <tr> 151 <td align="center" style="width: 150px; height: 30px"> 152 Team Name:</td> 153 <td align="center" style="width: 200px; height: 30px"> 154 <asp:DropDownList ID="DropDownList1" runat="server" CssClass="dropdownliststyle" DataSourceID="accessTeam" 155 DataTextField="TeamName" DataValueField="TeamID" AppendDataBoundItems="True" SelectedValue='<%# Bind("TeamID") %>'> 156 <asp:ListItem Value="" Selected="False">- Please Select -</asp:ListItem> 157 </asp:DropDownList> 158 <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="DropDownList2" 159 CssClass="errorMessage" ErrorMessage="Team Name is Required" ForeColor="">*</asp:RequiredFieldValidator></td> 160 </tr> 161 <tr> 162 <td align="center" style="width: 150px; height: 30px"> 163 I am a Manager:</td> 164 <td align="center" style="width: 200px; height: 30px"> 165 <asp:CheckBox ID="isManager" runat="server" Checked='<%# Bind("isManager") %>' Text="Yes" /></td> 166 </tr> 167 <tr> 168 <td align="center" style="width: 150px; height: 30px"> 169 I am a Team Manager:</td> 170 <td align="center" style="width: 200px; height: 30px"><asp:CheckBox ID="isTeamManager" runat="server" Checked='<%# Bind("isTeamManager") %>' Text="Yes" /></td> 171 </tr> 172 <tr> 173 <td align="center" style="width: 150px; height: 30px"> 174 MyManager is:</td> 175 <td align="center" style="width: 200px; height: 30px"> 176 <asp:DropDownList ID="myManagerIs" runat="server" CssClass="dropdownliststyle" DataSourceID="MyManager" 177 DataTextField="Name" DataValueField="id" AppendDataBoundItems="true" SelectedValue='<%# Bind("teamManagerID") %>'> 178 <asp:ListItem Value="" Selected="False">- Please Select -</asp:ListItem> 179 </asp:DropDownList> 180 </td> 181 </tr> 182 <tr> 183 <td align="center" style="width: 150px; height: 30px"> 184 Upload Image:</td> 185 <td align="center" style="width: 200px; height: 30px"> 186 <asp:FileUpload ID="UploadedFile" runat="server" 187 Width="150px" /> </td> 188 </tr> 189 <tr> 190 <td align="center" style="width: 150px; height: 30px"> 191 Image Title:</td> 192 <td align="center" style="width: 200px; height: 30px"> 193 <asp:TextBox ID="imagetitle" runat="server" CssClass="textboxstyle" Text='<%# Bind("imageTitle") %>' MaxLength="30"></asp:TextBox> 194 <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="imagetitle" 195 CssClass="errorMessage" ErrorMessage="Image Title is Required" ForeColor="">*</asp:RequiredFieldValidator></td> 196 </tr> 197 <tr> 198 <td align="center" style="width: 150px; height: 30px"> 199 Hide This Profile:</td> 200 <td align="center" style="width: 200px; height: 30px"> 201 <asp:CheckBox ID="profileHide" runat="server" Checked='<%# Bind("Display") %>' /></td> 202 </tr> 203 <tr> 204 <td align="center" colspan="2" style="height: 30px"> 205 <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("alternativeContact") %>'></asp:TextBox><br /> 206 <asp:LinkButton ID="selectedContact" runat="server" OnClick="selectedContact_Click" OnClientClick="selectedContact_Click">Add Selected Contacts</asp:LinkButton></td> 207 </tr> 208 <tr> 209 <td align="center" colspan="2" style="height: 30px"> 210 <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="errorMsgstyle" 211 ForeColor="" /> 212 </td> 213 </tr> 214 </table> 215 </InsertItemTemplate> 216 <HeaderTemplate> 217 218 </HeaderTemplate> 219 </asp:TemplateField> 220 <asp:TemplateField ShowHeader="False"> 221 <EditItemTemplate> 222 223 </EditItemTemplate> 224 <InsertItemTemplate> 225 <asp:LinkButton ID="btnInsert" runat="server" CausesValidation="True" CommandName="Insert" 226 Text="Insert"></asp:LinkButton> 227 <asp:LinkButton ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel" 228 Text="Cancel"></asp:LinkButton> 229 </InsertItemTemplate> 230 <ItemTemplate> 231 232 </ItemTemplate> 233 </asp:TemplateField> 234 </Fields> 235 </asp:DetailsView> 236 <br /> 237 <asp:Label ID="ErrorMessage" runat="server" CssClass="errortext"></asp:Label> <br /> 238 239 </td> 240 </tr> 241 <tr> 242 <td style="width: 100px"> 243 <asp:SqlDataSource ID="accessProfiles" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 244 InsertCommand="INSERT INTO [employeeDetails] ([isManager], [isTeamManager], [Name], [RoleID], , [extension], [mobile], [alternativeContact], [imageTitle], [imageMimeType], [imageData], [TeamID], [Display], [teamManagerID], [responsibilities], [hobbies]) VALUES (@isManager, @isTeamManager, @Name, @RoleID, @email, @extension, @mobile, @alternativeContact, @imageTitle, @MimeType, @imageData, @TeamID, @Display, @teamManagerID, @responsibilities, @hobbies)" > 245 <InsertParameters> 246 <asp:Parameter Name="isManager" Type="byte" DefaultValue="0" Size="1" /> 247 <asp:Parameter Name="isTeamManager" DefaultValue="0" Size="1" Type="Byte" /> 248 <asp:Parameter Name="Name" Type="String" /> 249 <asp:Parameter Name="RoleID" Type="Int32" /> 250 <asp:Parameter Name="email" Type="String" /> 251 <asp:Parameter Name="extension" Type="String" /> 252 <asp:Parameter Name="mobile" Type="String" /> 253 <asp:Parameter Name="alternativeContact" Type="String" /> 254 <asp:Parameter Name="imageTitle" Type="String" /> 255 <asp:Parameter Name="MimeType" Type="String" /> 256 <asp:Parameter Name="imageData" /> 257 <asp:Parameter Name="TeamID" Type="Int32" /> 258 <asp:Parameter Name="Display" type="Byte" DefaultValue="1" Size="0" /> 259 <asp:Parameter Name="teamManagerID" Type="Int32" /> 260 <asp:Parameter Name="responsibilities" Type="String" /> 261 <asp:Parameter Name="hobbies" Type="String" /> 262 </InsertParameters> 263 </asp:SqlDataSource> 264 <asp:SqlDataSource ID="accessrole" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 265 SelectCommand="SELECT [role], [RoleID] FROM [role] ORDER BY [role] DESC"></asp:SqlDataSource> 266 <asp:SqlDataSource ID="MyManager" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 267 SelectCommand="SELECT id, Name, isManager, isTeamManager FROM employeeDetails WHERE (isManager > 0) OR (isTeamManager > 0) ORDER BY Name DESC"> 268 </asp:SqlDataSource> 269 <asp:SqlDataSource ID="accessTeam" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 270 SelectCommand="SELECT [TeamID], [TeamName] FROM [Team] ORDER BY [TeamName] ASC"></asp:SqlDataSource> 271 <asp:SqlDataSource ID="getAlternatives" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 272 SelectCommand="SELECT [Name] FROM [employeeDetails] ORDER BY [Name]"></asp:SqlDataSource> 273 </td> 274 </tr> 275 </table> 276 </asp:Content> 277 278 Thanks for your help
View Replies !
View Related
Passing Multiple Values From A Listbox Into A Stored Procedure
hi i have a listbox with selectedmode = multiple, i am currently using this code in my code behind (c#) to call the storedprocedure within the datasource but its not working: Do i have to write specific code in c# to send the mulitple values through?protected void confButton_Click(object sender, EventArgs e) { try {foreach (ListItem item in authorsListBox4.Items) {if (item.Selected) { AddConfSqlDataSource.Insert(); } }saveStatusLabel.Text = "Save Successfull: The above publication has been saved"; }catch (Exception ex) {saveStatusLabel.Text = "Save Failed: The above publication failed to save" + ex.Message; } }
View Replies !
View Related
Sending Messages Which Have Multiple Values
We're looking to send messages to an SSB Queue (our 'Notification' queue) that contains multiple values.. like Message #1: 20,1 to indicate Record #20, send Notification #1.. the reason for this is we have lots of different types of records in our database, and based on certain conditions, we would like to send different notices regarding these various record types. What is the best format to send mesages like this? We thought about sending TABLE vars.. what other options are there?
View Replies !
View Related
Listbox Selected Values
Hi. With VWD i've produced the following code.<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:50469ConnectionString %>"SelectCommand="SELECT * FROM [ibs] WHERE ([liedID] = @liedID)"><SelectParameters><asp:ControlParameter ControlID="ListBox1" Name="liedID" PropertyName="SelectedValue" Type="Int16" />But the query is only returning one row of the table. Even when multiple values were selected in the ListBox1. Could someone tell me how to do?Thanks, Kin Wei.
View Replies !
View Related
Selected Listbox Values In SQL Statement
I have seen some information on this but have not understood fully the answers. I am fairly new to this and have spent the afternoon trying to work on this and although I have leant some really cool things I am no nearer. How do I get selected values from a LIstbox into a SQL statement using the IN command First I loop through a List box control to get the multi selected values: Dim li As ListItemFor Each li In lbPClass.Items If li.Selected = True Then strPC += li.Value & ", " End IfNextLabel5.Text = strPC The result in the lable looks something like: 100, 101, 102 , I get rid of the trailing blank and commar with:Label6.Text = Left(Label5.Text, Trim(Len(Label5.Text) - 2)) I have created a parameter called @PROPCLASS that will use the values from the selected values in the listbox in a SQL query using an IN statement: Cmd.Parameters.Add(New OleDbParameter("@PROPCLASS", Label6.Text)) strSQL = "SELECT * FROM web_transfer WHERE ( PROP_CLASS IN (@PROPCLASS)) AND (ACRES >= @lowSize)AND (ACRES < @HighSize) AND (YEAR = @lowYear)AND (SALE_PRICE > @lowPrice) AND (SALE_PRICE < @highPrice) " It is really the first bit of the WHERE clause I am interested in. The sql statement works if I either type in the actual values IN( 100, 101,102) or if I select only one value in the list box. If I select two then the sql statement does not work. My question is: How do I get the values selected in the List box into my SQL statement Thank you in advance, s
View Replies !
View Related
Use Listbox Values To Do Select Statement
Hi, I have SQL database 2000 which has one table Sheet1, I retrieved the columns in the ListBox, then chosed some of them and moved it to ListBox2. The past scenario worked great, and I checked the moved values, it was succesfully moved, but when I tried to copy the values in ArrayList to do a select statement it didn't worked at all. public string str;protected void Button3_Click(object sender, EventArgs e) {ArrayList itemsSelected = new ArrayList(); string sep = ","; //string str;for (int i = 0; i < ListBox2.Items.Count; i++) {if (ListBox2.Items[i].Selected) { itemsSelected.Add(ListBox2.Items[i].Value); } int itemsSelCount = itemsSelected.Count; // integer variable which holds the count of the selected items. str = ListBox2.Items[i].Value + sep; Response.Write(str); } SqlConnection SqlCon = new SqlConnection("Data Source=AJ-166DCCD87;Initial Catalog=stat_rpt;Integrated Security=True;Pooling=False"); String SQL1 = "SELECT " + str + " from Sheet1"; SqlDataAdapter Adptr = new SqlDataAdapter(SQL1, SqlCon); SqlCommandBuilder CB = new SqlCommandBuilder(Adptr);DataTable Dt = new DataTable(); Adptr.Fill(Dt); //return Dt; GridView1.DataBind(); SqlCon.Close(); } I did some changes and the new error message is Incorrect syntax near the keyword 'from'. Thank you
View Replies !
View Related
How To Insert All The Values From A Listbox Into The Database?
I want that the user can chose several options from one ‘listbox’, and to do this, I have created two ‘listbox’, in the first one there are the options to select, and the second one is empty. Then, in order to select the options I want the user have select one or more options from the first ‘listbox’ and then click in a link to pass the options selected to the second ‘listbox’. Thus, the valid options selected will be the text and values in the second ‘listbox’. I have seen this system in some websites, and I think it is very clear. Well, my question is, Is it possible to insert into the database all the values from a ‘listbox’ control? In my case from the second ‘listbox’ with all the values passed from the first one? If yes, in my database table I have to create one column (field) for every possible selected option? Thank you, Cesar
View Replies !
View Related
How Do I Store Multiple Selected Listbox Items
Hi There This is probably realy simple but since im still a newbie some help would be appreciated. I have a listbox bound to an sqldatasource which has names of people from my sql database employeeDetails table. I simply want to allow someone to select to select multiple names and insert them into another field in my database. I have this bit workng, ie they can select multiple people on the list, it does insert, however only the first selected name, not the others.Can you please help me out Kind Regads Dan
View Replies !
View Related
Multiple Selection Listbox As Data Control?
Hi, i have a listbox with multiple selection enabled, the end user uses this listbox to select what data they want to view eg. they select "green" to view all the green cars, "red" to select all the red cars etc. i have the listbox as the control that is connected to the datasource (the sql used for it is select * from cars_table where color =@colorthis works fine when one item in the listbox is selected, but when multiples are selected it does not work what format does the =@color have to be when multiples are selected? i've tried "green, red" "green + red" etc. but cannot seem to get it workingdoes anybody have any working examples that i can take a look at? it seems to be a common action, yet i cannot seem to find any documentation on how to get it to workthanks in advance!
View Replies !
View Related
Using Asp.net Listbox Control (multiple Selection) And Sproc
I have a form where a user can select multiple items from a listbox control.How can I pass each item selected to a sproc? Do i need to created a paramter for each item in my listbox in my sproc?Has anyone done this, I dont want to create dynamic sql to handle this and i dont really want to create 100 parameters to handle my listbox items.thanks
View Replies !
View Related
Sending Email To Multiple Recipient
I am trying to send emails to multiple recipient using the Send Mail Task, but it is failing with the error: "The specified string is not in the form required for an e-mail address." It works when I have only one emailID in the ToLine, I have a script task that build the emaiID list and saves it in a variable and the in the Send Mail Task, I am using the Expressions for ToLine to use this variable. If there is just one emailID in the list, everything works, but if there are multiple, it throws an error. For building the emailID list, I tried using "," as well as by ";". But none seem to work. Any help will be greatly appreciated.
View Replies !
View Related
Sending The Same Message To Multiple Servers
Can anyone outline some best practices for sending the same message out to multiple servers? What is the easiest way to do this? Currently, I have a message sent from Server A to Server B, which is fired by a table insert, update, delete trigger. The goal is to keep this table synchronized on many remote servers. It sounds like a tedious exercise to deploy the SSB messages, queues, services, etc to 20+ more sites! I am hoping there is a shortcut of some kind. Any advice is appreciated.
View Replies !
View Related
Retrieving Multiple Values From One Field In SQL Server For Use In Multiple Columsn In Reports
I am trying to create a report using Reporting Services. My problem right now is that the way the table is constructed, I am trying to pull 3 seperate values i.e. One is the number of Hours, One is the type of work, and the 3rd is the Grade, out of one column and place them in 3 seperate columns in the report. I can currently get one value but how to get the information I need to be able to use in my reports. So far what I've been working with SQL Reporting Services 2005 I love it and have made several reports, but this one has got me stumped. Any help would be appreciated. Thanks. I might not have made my problem quite clear enough. My table has one column labeled value. The value in that table is linked through an ID field to another table where the ID's are broken down to one ID =Number of Hours, One ID = Grade and One ID= type of work. What I'm trying to do is when using these ID's and seperate the value related to those ID's into 3 seperate columns in a query for using in Reporting Services to create the report As you can see, I'm attempting to change the name of the same column 3 times to reflect the correct information and then link them all to the person, where one person might have several entries in the other fields. As you can see I can change the names individually in queries and pull the information seperately, it's when roll them altogether is where I'm running into my problem Thanks for the suggestions that were made, I apoligize for not making the problem clearer. Here is a copy of what I'm attempting to accomplish. I didn't have it with me last night when posting. --Pulls the Service Opportunity SELECT cs.value AS "Service Opportunity" FROM Cstudent cs INNER JOIN cattribute ca ON ca.attributeid = cs.attributeid WHERE ca.name = 'Service Opportunity' --Pulls the Number of Hours SELECT cs.value AS 'Number of Hours' FROM Cstudent cs INNER JOIN cattribute ca ON ca.attributeid =cs.attributeid WHERE ca.name ='Num of Hours' --Pulls the Person Grade Level SELECT cs.value AS 'Grade' FROM Cstudent cs INNER JOIN cattribute ca ON ca.attributeid =cs.attributeid WHERE ca.name ='Grade' --Pulls the Person Number, First and Last Name and Grade Level SELECT s.personnumber, s.lastname, s.firstname, cs.value as "Grade" FROM student s INNER JOIN cperson cs ON cs.personid = s.personid INNER JOIN cattribute ca ON ca.attributeid = cs.attributeid WHERE cs.value =(SELECT cs.value AS 'Grade' WHERE ca.attributeid = cs.attributeid AND ca.name='Grade')
View Replies !
View Related
Multiple Columns With Different Values OR Single Column With Multiple Criteria?
Hi, I have multiple columns in a Single Table and i want to search values in different columns. My table structure is col1 (identity PK) col2 (varchar(max)) col3 (varchar(max)) I have created a single FULLTEXT on col2 & col3. suppose i want to search col2='engine' and col3='toyota' i write query as SELECT TBL.col2,TBL.col3 FROM TBL INNER JOIN CONTAINSTABLE(TBL,col2,'engine') TBL1 ON TBL.col1=TBL1.[key] INNER JOIN CONTAINSTABLE(TBL,col3,'toyota') TBL2 ON TBL.col1=TBL2.[key] Every thing works well if database is small. But now i have 20 million records in my database. Taking an exmaple there are 5million record with col2='engine' and only 1 record with col3='toyota', it take substantial time to find 1 record. I was thinking this i can address this issue if i merge both columns in a Single column, but i cannot figure out what format i save it in single column that i can use query to extract correct information. for e.g.; i was thinking to concatinate both fields like col4= ABengineBA + ABBToyotaBBA and in search i use SELECT TBL.col4 FROM TBL INNER JOIN CONTAINSTABLE(TBL,col4,' "ABengineBA" AND "ABBToyotaBBA"') TBL1 ON TBL.col1=TBL1.[key] Result = 1 row But it don't work in following scenario col4= ABengineBA + ABBCorola ToyotaBBA SELECT TBL.col4 FROM TBL INNER JOIN CONTAINSTABLE(TBL,col4,' "ABengineBA" AND "ABB*ToyotaBBA"') TBL1 ON TBL.col1=TBL1.[key] Result=0 Row Any idea how i can write second query to get result?
View Replies !
View Related
'Insert Into' For Multiple Values Given A Table Into Which The Values Need To Go
Please be easy on me...I haven't touched SQL for a year. Why given; Code Snippet USE [Patients] GO /****** Object: Table [dbo].[Patients] Script Date: 08/31/2007 22:09:29 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Patients]( [PID] [int] IDENTITY(1,1) NOT NULL, [ID] [varchar](50) NULL, [FirstName] [nvarchar](50) NULL, [LastName] [nvarchar](50) NULL, [DOB] [datetime] NULL, CONSTRAINT [PK_Patients] PRIMARY KEY CLUSTERED ( [PID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF do I get Msg 102, Level 15, State 1, Line 3 Incorrect syntax near ','. for the following; Code Snippet INSERT INTO Patients (ID, FirstName,LastName,DOB) VALUES ( '1234-12', 'Joe','Smith','3/1/1960'), ( '5432-30','Bob','Jones','3/1/1960'); Thank you, hazz
View Replies !
View Related
SqlDataReader - Pulling Multiple Values Into Multiple Variables
Hello all,I'm trying to request a number of URLS (one for each user) from my database, then place each of these results into a separate string variables. I believed that SqlDataReader could do this for me, but I am unsure of how to accomplish this, or if I am walking down the wrong road. The current code is below (the section in question is in bold), please ignore the fact that I'm using MySQL as the commands work in the same way. public partial class main : System.Web.UI.Page{ String UserName; String userId; String HiveConnectionString; String Current_Location; ArrayList Location; public String Location1; public String Location2; public String Location3; //Int32 x = 0; private void Page_Load(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { UserName = Membership.GetUser().ToString(); userId = Membership.GetUser().ProviderUserKey.ToString(); HiveConnectionString = "Database=hive;Data Source=localhost;User Id=hive_admin;Password=West7647"; using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(HiveConnectionString)) { // Map Updates MySql.Data.MySqlClient.MySqlCommand Locationcmd = new MySql.Data.MySqlClient.MySqlCommand( "SELECT Location FROM tracker WHERE Location = IsOnline = '1'"); Locationcmd.Parameters.Add("?PKID", MySql.Data.MySqlClient.MySqlDbType.VarChar, 255).Value = userId; Locationcmd.Connection = conn; conn.Open(); MySql.Data.MySqlClient.MySqlDataReader LocationReader = Locationcmd.ExecuteReader(); while (LocationReader.Read()) { Location1 = LocationReader.GetString(0); //Location2 = LocationReader.GetString(1); // This does not work.. } LocationReader.Close(); conn.Close(); // IP Display MySql.Data.MySqlClient.MySqlCommand Checkcmd = new MySql.Data.MySqlClient.MySqlCommand( "SELECT UserName FROM tracker WHERE PKID = ?PKID"); Checkcmd.Parameters.Add("?PKID", MySql.Data.MySqlClient.MySqlDbType.VarChar, 255).Value = userId; Checkcmd.Connection = conn; conn.Open(); object UserExists = Checkcmd.ExecuteScalar(); conn.Close(); if(UserExists == null) { MySql.Data.MySqlClient.MySqlCommand Insertcmd = new MySql.Data.MySqlClient.MySqlCommand( "INSERT INTO tracker (PKID, UserName, IpAddress, IsOnline) VALUES (?PKID, ?Username, ?IpAddress, 1)"); Insertcmd.Parameters.Add("?IpAddress", MySql.Data.MySqlClient.MySqlDbType.VarChar, 15).Value = Request.UserHostAddress; Insertcmd.Parameters.Add("?Username", MySql.Data.MySqlClient.MySqlDbType.VarChar, 255).Value = UserName; Insertcmd.Parameters.Add("?PKID", MySql.Data.MySqlClient.MySqlDbType.VarChar, 255).Value = userId; Insertcmd.Connection = conn; conn.Open(); Insertcmd.ExecuteNonQuery(); conn.Close(); } else { MySql.Data.MySqlClient.MySqlCommand Updatecmd = new MySql.Data.MySqlClient.MySqlCommand( "UPDATE tracker SET IpAddress = ?IpAddress, IsOnline = '1' WHERE UserName = ?Username AND PKID = ?PKID"); Updatecmd.Parameters.Add("?IpAddress", MySql.Data.MySqlClient.MySqlDbType.VarChar, 15).Value = Request.UserHostAddress; Updatecmd.Parameters.Add("?Username", MySql.Data.MySqlClient.MySqlDbType.VarChar, 255).Value = UserName; Updatecmd.Parameters.Add("?PKID", MySql.Data.MySqlClient.MySqlDbType.VarChar, 255).Value = userId; Updatecmd.Connection = conn; conn.Open(); Updatecmd.ExecuteNonQuery(); conn.Close(); } } } } Can anyone advise me on what I should be doing (even if its just a "you should be using this command) if this is not correct? In fact any pointers would be nice !Thanks everyone!
View Replies !
View Related
One Distributor Is Re-sending Transactions Another Stops Sending Altogether.
I'm running SQL Server 2000 SP2 transactional replication.Periodically replication fails due to primary key errors. Oninvestigation I find that the offending transaction is attempting toinsert a duplicate of a recently replicated row (identical dataincluding the rowtimestamp, which is automatically generated in thepublishing database). My conclusion is that the distributor issending the same transaction twice. There is usually a large block oftransactions that are duplicates. Replication has been removed andreinstalled with no change. Any suggestions on what might be causingthis problem?Another distributor/publisher replicating to the same subscriber ishaving the opposite problem. When replication is first set up,everything works fine. Then, a few hours or days later, I notice thatno new transactions have been replicated for some time. Thedistribution agent appears to be running normally with no errors andno transactions are queued in the distribution database. Thesubscription and publication are still active but new data stored tothe published articles that should be replicated are ignored. Againany suggestions on how to proceed would be greatly appreciated.We have many other systems replicating with no problems, some to thesame subbscriber and built from the same image. I plan to re-installSQL Server on both of these systems when operations allow, but I wouldreally like to find the root cause of this problem.ThanksWalt Smith
View Replies !
View Related
Compressing Multiple Rows With Null Values To One Row With Out Null Values After A Pivot Transform
I have a pivot transform that pivots a batch type. After the pivot, each batch type has its own row with null values for the other batch types that were pivoted. I want to group two fields and max() the remaining batch types so that the multiple rows are displayed on one row. I tried using the aggregate transform, but since the batch type field is a string, the max() function fails in the package. Is there another transform or can I use the aggragate transform another way so that the max() will work on a string? -- Ryan
View Replies !
View Related
ControlParameter
I am new to asp.net and this is the first time I have tried to use a ControlParameter from another control and I can not get it to work. FormView1 works as expected, but the controlParameter in SqlDataSource2 does not work as expected. A part of FormView1 and SqlDataSource1 (the source)<asp:FormView ID="FormView1" runat="server" DataKeyNames="Id" DataSourceID="SqlDataSource1" <ItemTemplate> <asp:Label ID="lblCategoryName" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label> </ItemTemplate> </asp:FormView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Id], [CategoryName], [ItemNumber], [Name], [Price], [SalePrice], [FullDescription], [ImageAltText], [DateSold] FROM [Products] WHERE ([Id] = @Id)"> <SelectParameters> <asp:QueryStringParameter Name="Id" QueryStringField="Id" DefaultValue="11" /> </SelectParameters> </asp:SqlDataSource> SqlDataSource2 (where I need to use "lblCategoryName" from FormView1) <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Id], [CategoryName], [ImageAltText], [DateSold] FROM [Products] WHERE ([CategoryName] = @CategoryName)"> <SelectParameters><asp:ControlParameter ControlID="FormView1" DefaultValue="Earrings" Name="lblCategoryName" PropertyName="text" Type="String" /> </SelectParameters> </asp:SqlDataSource> I hope someone can help me with my simple problem. Thank you
View Replies !
View Related
&<ASP:ControlParameter&> Is WEAK!!!
Don't you agree this control sux??you can only use source values from controls whose immediate container is Page. If I want to use a textbox inside something like a GridView, it's so much repetitive code to write in the case there's many textboxes that you want to use the values from.Wouldn't it be nice if you can specify any container in the page?Or --- it is possible to do that, but I didn't know?
View Replies !
View Related
SqlDataSource+ControlParameter+Textbox
Hi! I have a page (a search page) with sqldatasource, gridview and set of textboxes. The sqldatasource is using stored procedure with parameters. Using the visual wizard i'm associating the parameters with apropriate textboxes controls. It all works, like a charm. The problem arises when I input some dangerous code in any textbox , like ' or % . I'm having exception about unenclosed strings, generally info about the possibility of sql injection. I thought that using ControlParameters, any Parameter in fact is sqlinjection safe, but apparently it isn't. Does anyone know the right way of achieving my goal? It's very urgent.
View Replies !
View Related
How To Specify 2 Different Selectparameters - 1 For Querystringparameter And 1 For Controlparameter
Hello, I am sure there is a way to do this programmatically, but it is just not sinking in yet on how to go about this. I have a page where I use a dropdownlist that goes into a gridview and then the selected item of the gridview into the detailsview (typical explain seen online). So, when selecting from the dropdownlist, the gridview uses a controlparameter for the selectparameter to display the appropriate data in the gridview (and so on for the detailslist). My question is - I wanted to use this same page when coming in from a different page that would utilize querystring. So, the parameter in the querystring would be for what to filter on in the gridview, so the dropdownlist (and that associated controlparameter) should be ignored. Any suggestions on how to go about this? I assume there is some check of some sort I should in the code (like if querystring is present, use this querystringparameter, else use the controlparameter), but I am not sure exactly what I should check for and how to set up these parameters programmatically. Thanks, Jennifer
View Replies !
View Related
Set ControlParameter To Todays Date (vb)
Hi,I have the following sqldatasource on my page:<asp:SqlDataSource ID="rs1" runat="server" ConnectionString="<%$ ConnectionStrings:FrogConnectionString %>" SelectCommand="Proposals_DaySheet" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter ControlID="Calendar1" Name="FilterDate" PropertyName="SelectedDate" Type="DateTime" DefaultValue=""/></SelectParameters></asp:SqlDataSource>How do I set the default value to today's date ?I have tried:DefaultValue="<%# DateTime.Now %>"But I get:Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ControlParameter does not have a DataBinding event.I have also tried:DefaultValue="<%= DateTime.Now %>"But I get:System.FormatException: String was not recognized as a valid DateTime.Any ideas ?ThanksJames
View Replies !
View Related
How To Add ControlParameter To SqlDataSource At Runtime?
Hi! My question is exactly the subject. My Web Form has only a GridView and a DetailsView, there is no SqlDataSource at project time, i create the SqlDataSource at runtime using code like this in the Page_Load event: (I NEED IT TO BE CREATED DYNAMICALLY)1 Dim SQLDS As SqlDataSource = New SqlDataSource() 2 3 SQLDS.ID = "CustomerDataSource" 4 SQLDS.ConnectionString = ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString 5 SQLDS.SelectCommand = "select customerid,companyname,contactname,country from customers" 6 SQLDS.InsertCommand = "insert into customers(customerid,companyname,contactname,country) values(@customerid,@companyname,@contactname,@country)" 7 SQLDS.UpdateCommand = "update customers set companyname=@companyname,contactname=@contactname,country=@country where customerid=@customerid" 8 SQLDS.DeleteCommand = "delete from customers where customerid=@customerid" 9 10 SQLDS.UpdateParameters.Add(New Parameter("companyname")) 11 SQLDS.UpdateParameters.Add(New Parameter("contactname")) 12 SQLDS.UpdateParameters.Add(New Parameter("country")) 13 SQLDS.UpdateParameters.Add(New Parameter("customerid")) 14 15 Page.Controls.Add(SQLDS) 16 17 If Not Page.IsPostBack Then 18 GridView1.DataKeyNames = New String() {"customerid"} 19 GridView1.DataSourceID = SQLDS.ID 20 21 ' ... and so on The DetailsView1 uses the same SqlDataSource to show data, but i could not find a way to synchronize the DetailsView1 with the GridView1 when a record is selected in the GridView1.How can I synchronize the DetailsView?I played with the ControlParameter but i can't find either how to add a ControlParameter in code, is there a way? Every place talking about ControlParameter shows something like this: 1 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 2 ConnectionString="<%$ ConnectionStrings:Pubs %>" 3 SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE [state] = @state"> 4 <SelectParameters> 5 <asp:ControlParameter Name="state" ControlID="DropDownList1" PropertyName="SelectedValue" /> 6 </SelectParameters> 7 </asp:SqlDataSource> 8 Ok. OK. But my SqlDataSource is created dynamically. Any ideas on how to solve this problem?Thanks!
View Replies !
View Related
Could Not Find Control '' In ControlParameter ''
Hello All I have a repeater with controls, some draw from different SqlDatasources. Everything loads up properly, I click my update button and then I get the error: "Could not find control 'txtProjectName' in ControlParameter 'projectName'" The Control txtProjectName is in the repeater <itemTemplate> <asp:TextBox ID="txtProjectName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "projectName") %>' /> My Datasource that I want to update looks like this: <asp:SqlDataSource ID="dsEditProject" runat="server" ConnectionString="<%$ ConnectionStrings:webtoolConn %>" > <UpdateParameters> <asp:ControlParameter ControlID="txtProjectName" PropertyName="Textbox.Text" Name="projectName" Type="String" /> </UpdateParameters> My code behind looks like this: Protected Sub rptEditProject_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptEditProject.ItemCommand Dim projectId As String = Request.QueryString("projectId") dsEditProject.UpdateCommand = "UPDATE [projects] SET [projectName] = @projectName WHERE [projectId] = " & projectId & ";" dsEditProject.Update() End Sub It gets to the dsEditProject.Update and errors saying it can't find the control. If I hard code the "@projectName" in the update command everything works. It just isn't setting the parameterControl to what is in the textbox. Also, if I set the parameter with asp:parameter it will put in whatever I put as the default. How do I get the controlParameter to grab what is in txtProjectName? Many thanks Don
View Replies !
View Related
ControlParameter And Stored Procedures
I'm sure I'm missing something silly. I have 3 textboxes, a stored procedure and a gridview. The user will put something in the 3 boxes, click submit, and see a grid with stuff (I hope). However, the grid will only return data is I EXCLUDE the controlparameters and only use the sessionparameter. It's like the stored proc won't even fire! HTML: <form id="form1" runat="server"><div>Lastname: <asp:textbox id="Lastname" runat="server"></asp:textbox>Hobbies: <asp:textbox id="Hobbies" runat="server"></asp:textbox><br />Profession: <asp:textbox id="Profession" runat="server"></asp:textbox><asp:button id="Button1" runat="server" text="Button" /><br /><asp:gridview skinid="DataGrid" id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1"><columns><asp:boundfield datafield="Username" headertext="Username" sortexpression="Username" /><asp:boundfield datafield="Lastname" headertext="Lastname" sortexpression="Lastname" /><asp:boundfield datafield="Firstname" headertext="Firstname" sortexpression="Firstname" /></columns></asp:gridview> <asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:HOAConnectionString %>"selectcommand="spAddressBookSelect" selectcommandtype="StoredProcedure"><selectparameters><asp:sessionparameter defaultvalue="0" name="CommunityID" sessionfield="CommunityID" type="Int32" /><asp:controlparameter controlid="Lastname" name="Lastname" propertyname="Text" type="String" /><asp:controlparameter controlid="Profession" name="Profession" propertyname="Text" type="String" /><asp:controlparameter controlid="Hobbies" name="Hobbies" propertyname="Text" type="String" /></selectparameters></asp:sqldatasource> </div> </form> sp signature:ALTER PROCEDURE [dbo].[spAddressBookSelect] @CommunityID int = 0,@Lastname varchar(200) = NULL,@Profession varchar(200) = NULL,@Hobbies varchar(200) = NULL
View Replies !
View Related
Load ControlParameter From Page's Peoperties
Hi,in aspx I've SqlDataSource, in SelectParametersI can add ControlParameter and to load parametersfrom control Property, BUT I'm trying to do that:Is there way, when in <ControlParameter>to set parameter to be loaded from PAGE Property.something like that:aspx:<asp:SqlDataSource ID="_companyDS" runat="server" ConnectionString="<%$ ConnectionStrings:tihomir_dbConnectionString %>" SelectCommand="SELECT [companyID], [companyName], [companyInfo], [companyAddress] FROM [Companies] WHERE ([companyID] = @companyID)"> <SelectParameters> <asp:ControlParameter ControlID="Page" PropertyName="CompanyIdent" Name="companyID" Type="Int32" DefaultValue="0" /> </SelectParameters> </asp:SqlDataSource></asp:SqlDataSource>code behind:public partial class test : System.Web.UI.Page{ public int CompanyIdent { get { return ... some id ...; } }} Best Regards,Tihomir Ivanov Best Manager Software
View Replies !
View Related
How To Progtammatically Manipulate Property 'Name' Of ControlParameter?
Hi, i want to programmatically manipulate the property 'Name' of a ControlParameter inside a InsertParameters tag. This the aspx code: ------------------ <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<% ......... %>" InsertCommand="INSERT INTO .......)" <InsertParameters> <asp:ControlParameter Name="myname" ControlID="na" PropertyName="text" /> </InsertParameters> </asp:SqlDataSource> code-behind: ------------ Dim a As String a = SqlDataSource1.InsertParameters.Item(0).ToString but 'm stuck here Thanks for help Tartuffe
View Replies !
View Related
Can A ControlParameter Be Used To Supply A Parameter For A Stored Procedure?
The code below is an attempt at using the value from a dropdownlist to feed into stored procedure outlined in the Select command. I have seen examples where the control parameter is used with a select command but nothing where the parameter has to be fed into a stored procedure. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=".."SelectCommand="procCAGetCustomerKPIs" SelectCommandType="StoredProcedure"><SelectParameters><asp:ControlParameter Name="iCustomerGroupId" ControlID="CustomerFilterList" PropertyName="SelectedValue" /></SelectParameters></asp:SqlDataSource> cheers-jim.
View Replies !
View Related
Passing Parameters To SQL Stored Procedure With SQLDataSource And ControlParameter
Hello, I'm having trouble executing a Stored Procedure when I leave the input field empty on a 'search' criteria field. I presume the error is Null/Empty related. The Stored Procedure works correctly when running in isolation. (with the parameter set to either empty or populated) When the application is run and the input text field has one or more characters in it then the Stored Procedure works as expected as well. Code: . . <td style="width: 3px"> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> </td> . . <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="LogId" DataSourceID="SqlDataSource1" Width="533px"> <Columns> <asp:BoundField DataField="LogId" HeaderText="Log Id" InsertVisible="False" ReadOnly="True" SortExpression="LogId" /> <asp:BoundField DataField="SubmittedBy" HeaderText="Submitted By" SortExpression="SubmittedBy" /> <asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" /> <asp:TemplateField> <ItemTemplate> <span> <asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink></span> </ItemTemplate> </asp:TemplateField> </Columns> <HeaderStyle BackColor="#608FC8" /> <AlternatingRowStyle BackColor="#FFFFC0" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SmallCompanyCS %>" SelectCommand="spViewLog" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="txtName" ConvertEmptyStringToNull="true" Name="name" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> Stored Procedure: ALTER PROCEDURE dbo.spViewLog (@name varchar(50) ) AS SELECT * FROM log_Hdr WHERE (log_hdr.submittedby LIKE '%' + @name + '%') RETURN I have tried the 'convertemptystringtonull' parameter but this didn't seem to work. Any guidance would be much appreciated. Thank you Lee
View Replies !
View Related
Multiple Values
PO table has itemnum - over 16000 records closedate - can be 2001, 2002 location - is 1, 2, 3 etc Like to find itemnum where location is 1 and itemnum has closedate of 2001, if it does have close date of 2001 than check if another record of same item with closedate of 2002. If yes, than diplay that item. The result would be itemnum which have closedate of 2001 as well as 2002. Each item may have more than one record for each year.
View Replies !
View Related
MAX With Multiple Values.
Hi. I;m trying to sort out some values. Ok so for sort. We have a contract and a renewal column. A contract can have many renewals. I'm trying to get the latest renewal for each contract (latest renewal is the one with the higher number. so im trying this.. select distinct c.policyno,c.renewalno from CONTRACT AS c inner join multicontract as d ON c.multicontractID = d.ID where c.renewalno in (select max(crn.renewalno) from contract crn where c.id= crn.id But i keep getting multiple results (p.e. contra 12 ,renewal 13,14,15 and i want contract 12, renewal 15) Any help?
View Replies !
View Related
Inserting Multiple Values
Hi there I have an exel spreadsheet with a very long list of towns. How can I import/insert that into my "Towns" table in sql express? I can't seem to find any way to import it and I'm not sure how to do multiple inserts. Thanks
View Replies !
View Related
Insert Multiple Row Values
hi everyone how do i insert multiple rows in a database ? i came up with something like this after googling but it does not work INSERT INTO tblSold (LID, BuyerID,Date)select ('759','2106','2441') UNION ALLselect ('0','0','0') UNION ALLselect ('10/25/2007','10/25/2007','10/25/2007')
View Replies !
View Related
Multiple Return Values
I have a situation where I need two values (both are integers) returned from a stored procedure. (SQL 2000) Right now, I use the statement "return @@Identity" for a single value, but there is another variable assigned in the procedure, @NewCounselingRecordID that I need to pass back to the calling class method. I was thinking of concatenating the two values as a string and parsing them out after they are passed back to the calling method. It would look something like "21:17", with the colon character acting as a delimiter. However, I feel this solution is kludgy. Is there a more correct way to accomplish this? Thanks in advance for your comments.
View Replies !
View Related
Need To Declare Multiple Values
Alright, so I have this problem. I want to make it easy for me andothers to be able to run a query and easily choose whether we wantMerchants or NonMerchants. Previously, we would have to comment outbits of code and would leave things messy (it would also leave room forerror). So, I'm thought DECLARE and SET would work. Wrong.This is what I have....DECLARE @Merchant VARCHARSET @Merchant = (Select CONVERT(VARCHAR, Id) + ','FROM AdminAdvertiserTypesDDLWHERE Id IN (1,3,4,5)) // Includes Active, Out of Business, Cease to do business, InactiveI've also tried...SET @Merchant = '1,3,4,5'Then, in the query itself I try:WHERE AdminAdvertiserTypesDDL.Id = @MerchantorWHERE AdminAdvertiserTypesDDL.Id IN @MerchantorWHERE AdminAdvertiserTypesDDL.Id IN (@Merchant)orWHERE AdminAdvertiserTypesDDL.Id LIKE @MerchantEither way, it will ONLY show me the merchants whose Id is 1. When Imake the query:WHERE AdminAdvertiserTypesDDL.Id IN (1,3,4,5)I finally get the desired results.Any ideas or tips?Thank you so much!
View Replies !
View Related
Multiple Values In One Column
I'm trying to write a query which allows that multiple values from onecolumn are placed in one record.ex:tableNrLetters1A2A2B2C3A3B3C3D3E4AThe result I want to get from an select:NrAll Letters1A2A, B, C3A, B, C, D, E4AOlivier
View Replies !
View Related
Columns With Multiple Values ??
Hi, The values I need to store in the table are Student ID Student Name Subjects The "Student ID" is the primary key. A student can take more than 1 subject. For example: Student ID: 100 Student Name: Kelly Preston Subjects: Geography, History, Math How can I store these values in a database table? I know the normal "INSERT" statement, but how would I store the multiple subjects for a single student ID? My "Student ID" is auto generated. If I create a new row for each subject, the Student ID will be different for each subject, which I dont want. Or I can create a new field called "RowNumber" and keep that the primary key.. For example: Row Number StudentID StudentName Subject 1 100 Kelly Geography 2 100 Kelly History 3 100 Kelly Math If this is the only way to store the multiple sibjects, then for a given student ID (say 100), how can I retreieve the associated name and subjects? What is the query for that?
View Replies !
View Related
Multiple Values For Single Row
hi iam totally new to databases , as a project i have to design a database of users...they have to register first like any site..so i used stored procs and made entries to database using insert command...its working for now..now every user will search and add other users in the database..so every user will have a contact list...i have no idea how to implement this...so far i created a table 'UserAccount' with column names as UserName as varchar(50)Password as varchar(50)EmailID as varchar(100)DateOfJoining as datetimeUserID as int ---> this is unique for user..i enabled automatic increment..and this is primary key..so now every user must have a list of other userid's.. as contact list..Any help any ideas will be great since i have no clue how to put multiple values for each row..i didnt even know how to search for this problems solution..iam sorry if this posted somewhere else..THANK YOU !if it helps..iam using sql server express edition..and iam accessing using asp.net/C#
View Replies !
View Related
Insert Multiple Values
i have about 2,000 record and i need to insert them in my table. how do i insert these informations using this syntax?? au_id au_name au_fname 1003 vivian latin 1005 cecy mani 1004 bili david insert into autors (au_id, au_name,au_fname) Values ('1101', 'Rabit','jesicca') thanks for your time and help.
View Replies !
View Related
Finding Multiple Values
Hello, I have a web form with a check box list with 5 values. Each of them is an int value, and the user can select multiple values from the check box list. For example: Status: 1) Single 2) Married 3) In Relationship 4) Divorced 5) Any These values correspond to a column called "RelationshipStatus" which holds an int value of NULL or 0-5. So the value passed to my SQL query would be any combination of 1, 2, 3, 4, or 5 (Which denote any of the above). It could look like this: @Status = '132' Now my question is how would I do a select statement that finds any row with one of those value (Any row with 1, or 3, or 2)? If there is a '5' in the varible then the select statement should return any row regardless of the value. Table Name: "USER_TABLE" Column Name: "Relationship_Status" Value Type: INT Thank you experts!
View Replies !
View Related
Update With Multiple Values
I have a table say #temp1 with coulmn Id and Description and I do have another table #temp2 with column id and Projectdescription but in #temp2 there could be more then one value against one id like the data in #temp2 is look like id Projectdescription 1 Computer project 1 update in computer project 1 another update in computer 2 Physics project 2 another update but #temp1 has only one accurance of id and data initially looks like id Description 1 NUll 2 NUll and I would like to update this table description from #temp2 Projectdescription column so that data in #temp1 table look like after update id Description 1 Computer project,update in computer project, another update in computer 2 Physics project, another update I mean I would like to have concatination form of Projectdescription in description column against specific ID I can achieve this by using UDF but i dont want to use that I just want to do it by update statement not even by using cursor
View Replies !
View Related
|