Populate Arraylist From A Database
Sep 15, 2006Hi
i'm pretty new to this, how do i connect to my database a put all the values from one column into the arraylist.
Any help and a easy example would be nice
Thanks in advance
Richard
Hi
i'm pretty new to this, how do i connect to my database a put all the values from one column into the arraylist.
Any help and a easy example would be nice
Thanks in advance
Richard
In my data access layer class I have Populate methods on the bottom.One of the the objects, color, is an ArrayList, how do I write that? private Product PopulateProduct(IDataReader r) { Product product = new Product(); product.BrandId = Convert.ToInt32(r["brandId"]); product.BrandName = Convert.ToString(r["brandName"]); product.Color = whatGoesHere? (r["color"]); return product; } thanks
View 4 Replies View RelatedI have 3 strings delimitted by a * character that I would like to save to a database. Each string will always have the same number of elements.
strUserID = "1*2*3"
strCompanyID="12931*12937*12945"
strCompanyName="International Business Machines, Inc*Ford Motor Company*Delta Airlines"
What I need to do is to save each record like this
INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (1, 12931, 'International Business Machines, Inc')
INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (2, 12937, 'Ford Motor Company')
INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (3, 12945, 'Delta Airlines')
I've done something like this before with a single string, but don't know how to handle 3 of them.
Dim strAlerts As String() = NothingstrAlerts = values.Split(",")Dim s As String For Each s In strAlerts SqlText = "INSERT INTO tableA (UserID, CompanyID, CompanyName) VALUES (" & lblUserID.Text & ", '" & lblCompanyID.Text & "','" & s & "')" cmd = New SqlCommand(SqlText, strSQLConn) cmd.ExecuteNonQuery() Next s
Thanks for any help
I am trying to add a number of dates into a Sql database. Basically I want the user to add the start and end date and then all the dates in between are are added to a database in unique records. I can create an ArrayList but I don't know how to bind it to an SqlDataSource Dim startdate As DateTime = tbstartdate.Text Dim enddate As DateTime = tbenddate.Text Dim datediff As TimeSpan = enddate.Subtract(startdate) Dim noofdays As Integer = datediff.Days Dim ar As New ArrayList Dim i For i = 0 To noofdays ar.Add(startdate.AddDays(i)) Next Sorry if this is a total noob question....
View 1 Replies View RelatedHi
I have an arraylist that contains the names of those userid's that i need to check in an online db to check out if they are online now.If the UserId column of the SqlTable matches any of the name of that of the arraylist, then i need to import the values of two corresponding fields say age, Nick etc.I would be very grateful to anyone who could kindly tell me how to do this in an Sql Query i.e How to actually send an arraylist into sql query or any other way around this problem.
Say the arraylist to be verified against the table is:public ArrayList BuddyList = new ArrayList();
Thank You.
Regards.
I have an SQL command below that works fine
"SELECT sum(Preference) FROM [projectDB].[dbo].[Vote] group by preference;SqlDataReader datareader = cmdPres.ExecuteReader();ArrayList myArr = new ArrayList();
when i read the data in the values i get are10,14,10,17
I want to loop through the reader, then add the values to an arrayList. Then i want to check of the value in the arrayList is greater than 15 but it dosent work. I get an error message when i add sum(Prefernece) to the arraylist, it will not allow me.
while (dreader.Read()){myArr.Add(datareader["sum(Preference)"].ToString());if(myArr.??? > 15){Response.Write("Its greater than 15");}}
Hi,
I have a custom task to execute a package. This task sets dynamically the values of the child package at runtime before execution of the child.
Everything works fine, as long as Im not trying to use an Object Variable in the child package, trying to fill with an ArrayList. Then, during package validation at runtime, the Properties of the custom task have NULL-Values. I don't know why all Properties got NULL or 0 (int), only adding an ArrayList-Property to the Task-Code.
The ArrayList gets initialized in the constructor of the Task. Values to add in execute(). But the process never gets to the execute()-Method, due to my check in validate() for null Values. So the List is initialized but empty.
Anyone an idea, maybe I'm doing something wrong at all. Anybody experiences with Object-Variables in Packages? A HowTo?
Thanks a lot
Thorsten
I have two Databases with the same name that reside in different servers. The two servers are linked servers. Each database consists of 5 Tables. The tables have identical names in each database.
The database in ServerA has 5 tables with data, the database in ServerB also has 5 tables with the same schema as ServerA, however the 5 identical tables in ServerB contain no data.
I need to populate the 5 tables in ServerB with the Data from the 5 tables in ServerA.
What SQL code or script can i use to populate the 5 tables in ServerB
Below are the names of the 5 tables:
TABLE1: [ServerB].[ProdDB].dbo.[Orders]
TABLE2: [ServerB].[ProdDB].dbo.[Sales]
TABLE3: [ServerB].[ProdDB].dbo.[Employee]
TABLE4: [ServerB].[ProdDB].dbo.[Customer]
TABLE5: [ServerB].[ProdDB].dbo.[Region]
Does any one have a script that could help me with this task. Thanks
I am using SQL Server 2005
Hi, I want to populate the array with a single column values from database(sqlserver 2000)Ex. name ageaaaa 23bbbb 43cccc 18 Now i want to populate the array with name field values. Please anyone guide me how to do this.Thanks in advanceBala
I am writing a small program (Visual Studio Express 2008) to help me automate populating a database graphically. The program I am writing will keep track of sales figures state by state on a map of the US. This will be accomplished by using a map of the United States overlaid with a hexagonal grid that represents individual sales regions (hexagons). Each hexagon represents a specific sales region, and there can be many sales regions within a state. This small program will populate the database with data specific to each hexagon that is selected by clicking on it with a mouse. A complete set of row entries should be sent to the database every time the mouse is clicked in a hexagon on my map. This program will capture such information as the center x,y pixel coordinates of each hexagon, row & column location of each hexagon, and the state where the hexagon is located. All of this information (HexX, HexY, RowX, RowY, State) has already been figured out or calculated, except that I need help on how to capture, display, and send this information as a new row entry into my database. I need to populate the database hexagon by hexagon, since which state they are in is determined visually.
Here is what I need to populate my database with:
Hex_No - each unique hexagon needs to have its own unique number 1,2,3,€¦.n. This should be as easy as assigning a counter that starts at 1 and increments until all hexagons have been processed
Hex_X €“ the pixel x value of the center (x,y) of the specific hexagon, which is known by the program
Hex_Y €“ pixel y value of the center (x,y) of the specific hexagon, which is known by the program
Hex_Col €“ column location of this specific hexagon, which is known by the program
Hex_Row€“ row location of this specific hexagon, which is known by the program
State €“ the current state on the map. This will be selected by me (combobox) prior to clicking on each hexagon within a given state
Each of the above is represented by a textbox on a form, except for the State field, which is represented by a combobox. When one clicks on the down arrow of the combobox, one can see that the names of the different states have already been entered and linked to the SQL database. The other textboxes are also linked to a different column in the same database; however they are currently empty due to the fact that this is the very data that needs to be captured by this program. This is what I need for this program to do for every mouse click , once I have moved on to a given hexagon within a given state:
Determine next available Hexagon Number, and assign it to current hexagon, display in textbox, send this as part of row data entry under Hexagon_No column
Capture and display the current hexagon€™s center x, and y (Hex_X, Hex_Y), display this in textbox, send this as part of row data entry under Hex_X, and Hex_Y columns
Capture and display the current hexagon€™s row and column information (Hex_Col, Hex_Row), display this in textbox, send this as part of row data entry under Hex_Col, and Hex_Row columns
Capture and display the current State that is selected manually from the list of database values, send this as part of row data entry under State column
Here is an example of what this program might look like in action:
http://farm4.static.flickr.com/3172/2285817199_d75f230f8d_o.jpg
I am not looking for anyone to write my program, but I would appreciate some ideas on how I can accomplish this. I have figured everything out except the part about displaying the new information on the textbox/combobox form, and sending it to the database as the next row entry. That€™s the part I need help with.
Thanks.
hi
i have a database with a table with several columns:
ID - primery key
customer
company
now lets say i want to edit one row in the database and i have the primery key ID for that row. so i click on that row (which is displayed in a gridview) when i click I want the text that is in the customer cell to appear in a textbox1 and the same with compeny text I want it to apear in another textbox2.
so what code can i write in the GridView1_SelectedIndexChanged eventhandler to populate the textboxes?
thank you
Im a newbie with a sql table in a MSDE database that contains fields ofCustName, BrokerName, Type, Status.I am trying to write a trigger that does this:1. When a new record in a table is added, I would like the selectedfields to be copied to another table (call it Master).2. If that Master table already contains a record where the CustName =CustName, then simply ignore. If CustName does not match anything, thenadd the record to the Master TableIn other words, I am trying to create a table (or even a new database)that has unique records in it - making a master customer list.Any hints on how to get started on this?
View 6 Replies View RelatedHi,
I need to write a reporting app that process daily IIS logs that are averaging about 299MB a day!
I am considering using SSIS to put the log data into a sql server 2005 database.
Has anyone done this? Or does anyone know if it is possible? And without using the MS LogParser?
Thanks in advance and any help greatly appreciated!
Regards,
kitquo2.
Hi
I'd like to be a little more efficient in my approach when using databases. Although my site is very simple with a low hit rate expected, I would still like to learn the best methods in designing server load conscious code.
Basically, I have a page where I'd like to show events broken down into days of the week (Monday - Sunday). All the events contain the same data and only difference being the day. Right now, the only way I know how to make this work is to create a unique sqlDataSource (select * where Day = Monday) then assign it to a ‘Monday’ grid view. I then repeat this same process for each day of the week.
As the data is always the same, is there a way to make only call to the database returning all the data, then close the connection and then separate the data there after. To me this seems to be a much more efficient way to manage the data???
Thanks for any help/supportRichard
I am using SQL server to create a rather complicated client database for a nonprofit organization. I have access to an ancient version of the database in Access format, but would rather create a new database from scratch instead of "up-sizing" the old database. Although the old database is mostly useless, it contains a goldmine of names and addresses that I could use to populate the new database that I'm creating. My question is this: Is there any relatively easy way to cut and paste from external data sources into a new SQL database? For example, I would love to just select twenty rows of "first names" from the old database and then paste that into my new table. Can anyone suggest any quick and easy tricks for populating a new database with place-holder content? Thanks!
View 2 Replies View RelatedI am trying to load in to a new application's database to see if my load procedures will be able to handle the volume and how long I should plan on when I perform our cut over for production. Unfortunately, trying to copy 5.4M rows from one staging table into a production processing table consistently leaves the database in a suspect status, usually stating to perform some type of disk consistency check utility. It happens time after time, is there anything obvious that I could look at to see why this is happening?
View 3 Replies View RelatedThe problem is that I have (for example) following data
AAAA AA ALH
B BBB MIL
CCCCCC CAC Q
D D P
in space delimited file and i want to populate a database using SSIS and it is not working. Any suggestions will be appreciated.
P.S. the only way to recognize colums is through spaces b/w the data.
Hi,
I accidentally populate tables into System databases/master database. What should I do? Should I delete all the tables I populate in mster database?
Thank you very much!
the subject pretty much says it all, I want to be able to do the following in in VB.net code):
{[If [table with this name] already exists [in this sql database] then [ don't create another one] else [create it and populate it with these values]}
How would I do this?
Anybody see a reason why this list won't populate?
<asp:DropDownList ID="ddlState" DataSourceID="srcStates" DataTextField="StateName" DataValueField="StateName" runat="server"> <asp:ListItem>Select State</asp:ListItem></asp:DropDownList><asp:SqlDataSource ID="srcStates" runat="server" ConnectionString="<%$ ConnectionStrings:webConn %>" SelectCommand="sp_States" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="ddlState" DefaultValue="Select State" Name="State" PropertyName="SelectedValue" Type="String" /> </SelectParameters></asp:SqlDataSource>
Sorry if this is to basic but I am just starting out. Any help is appreciated.
Basically I am attempting to populate a listbox with items from a MSSQL DB so the user can select either one or multiple items in that listbox to search on.
I have data like below, I need to populate the ID_INDICATOR columns with the below condition
ID TASK_ID TASK_COMPLETEDTSTASK_DUETSTASK_INDICATORID_INDICATOR
112014-06-09 00:00:002014-06-11 00:00:00GREEN
122014-06-13 00:00:002014-06-14 00:00:00AMBER
132014-06-17 00:00:002014-06-16 00:00:00RED
142014-06-17 00:00:002014-06-18 00:00:00AMBER
Condition:
##########
Red = If ID due date was overdue, i.e. if last task completed after the ID end date(2014-06-18 00:00:00).
AMBER= If any task in the ID is overdue but completed before the ID end date(2014-06-18 00:00:00)
Green = If all tasks were completed on time.
I am looking for the logic to implement the AMBER for the whole ID, because the TASK_ID 3 is overdue, but completed before the ID end date (2014-06-18 00:00:00).
I am trying to update a name column in the following way: (I wrote a description, but I think this visual is easier to understand).
This is what I have:
name1 name2 address etc
Bob null 123 street
Sue null 123 street
Jack null ABC circle
This is what I want:
name1 name2 address etc
Bob Sue 123 street
Jack null ABC circle
I'm just trying to get 2 names on the same row if they have the same address and get rid of the spare row. Name2 is currently null. Seems simple enough but I don't know how to do it in SQL. I can do it in FoxPro, but that doesn't help me here.
Thanks for any ideas.
I added an index to a SQL Server 2005 table. How do I populate that index? I thought it might be automatically populated but the operation to add the index happened so quickly that I don't think it could have done it that quickly. Also, I expected faster performace when selecting rows based on the indexed column, but performance remains the same.
View 1 Replies View RelatedDuring a dataflow - I like to populate a variable with True or False based on a value in one of the data records.
How do I do this excercise ?
if I use a script - can someone provide me with simple script on how to populate one variable ?
Thanks heaps
Here is what I have and (somewhat understand). I’m using Visual Web
Developer 2005 Express Edition and have setup my application to use form authentication
(which automatically creates the ASPNETDB.MDF file with several default tables
and views). I’m using the CreateUserWizard
which is fine…but I need to collect additional information like (firstname,
lastname, address…and on..). What I’ve
done. I’ve created a tabled named
UserProfile and set UserId as the primary key (uniqueidentifier).
I then setup a 1-to-1 relationship
between aspnet_Users and UserProfile (which I think is correct). On my UpdateContactInfo.aspx page (where
users go to update their personal information) I use a hidden label control
(UserValue) to receive the UserId during the page_load event as below:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load UserValue.Text = Membership.GetUser().ProviderUserKey().ToString() End Sub Now with the UserID available I need to populate the
UserProfile table with the UserId, firstname, lastname, address of the
currently logged in user. How can I do this and am I on the
right track..?
We have stored large text data in "Image" data type in SQL Server. Can someone tell me how to get that vlaue from image datafield. Thanks
View 3 Replies View RelatedUsing the SqlDataReader, I am retrieveing records from a SQL Server 2005 DB table. Since I am using the SqlDataReader to retrieve the records from the DB, I have to use the Read method of the SqlDataReader like this:Dim sqlReader As SqlDataReaderWhile(sqlReader.Read) Response.Write(sqlReader.GetValue(0) & "<br>") Response.Write(sqlReader.GetValue(1) & "<br>") Response.Write(sqlReader.GetValue(2) & "<br>")End WhileThe records retrieved can only be accessed inside the While loop. I want to access the records outside the While loop as well. Is there anyway by which I can do this, maybe by populating the recordset in an array variable & then using it outside the While loop?
View 3 Replies View Related Hi there!I'm trying to populate automactly a record in a table. I've tried this: <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ProducaoLigacao %>" SelectCommand="UPDATE [Producao] SET [Prodas] = @Prodas WHERE ([ProdUserID] = @ProdUserID)">
<UpdateParameters>
<asp:Parameter DefaultValue="1" Name="ProdUserID" Type="Int32" />
<asp:Parameter DefaultValue="999" Name="Prodas" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource> Is this possible? Thanks in advance!
I have been attempting to populate a dropdown (combo) box from a SQL query (SQLConnector) in Web Matrix and I have so far been unsuccessful. I have been able to populate a DataGrid just fine from the query, so then I limited it down to one colum (so itd be in the dropdown box) and set all the properties I could find (DataSource, DataMember, DataTextField, DataValueField) (and in all possible combinations) for that dropdown box to the SQL stuff (SQLConnector for the DataSource and then used the dropdowns for the others), and nothing shows up in my dropdown box. How can I make this populate off of my SQL query properly?
Additionally I will need to do the same thing for a Checkbox List so if it is the same and you know how to do that and could let me know for that too that'd be great.
Thanks a million in advance!
I have a dropdownlist that is populated from a DB table. I would like to also include any other values that might be in another table. How do I combine these two queries, so I can get distinct values from both tables combined?SELECT Category
FROM dbo.TABLE1
GROUP BY Category
SELECT Category
FROM dbo.TABLE2
GROUP BY Category
Can someone tell me what I am doing wrong... I am trying to populate some textboxes from a table by doing a SELECT statment.
Any help would be greatly appreciated
T.
Code:
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
myConnection = New SqlConnection("Server=.SQLEXPRESS;AttachDbFilename=|DataDirectory|CustomerInfo.mdf;Integrated Security=True;User Instance=True")
myCommand = New SqlDataAdapter("SELECT * FROM [CustomerSalesNum] WHERE [WorkSheetID]= '" & lblRWorkSheetID.Text & "'", myConnection)
Dim ds As DataSet = New DataSet("CustomerSalesNum")
ds = New DataSet("CustomerSalesNums")
tbUPPRice.Text = ds.Tables["CustomerSalesNums"].Rows[0]["Price"].ToString();
does any one know how to built a star schema by DTS:confused:
View 4 Replies View Related