Saving Arraylist To A Database
Apr 17, 2007
I 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() = Nothing
strAlerts = 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
View 5 Replies
ADVERTISEMENT
Sep 15, 2006
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
View 4 Replies
View Related
Jan 18, 2007
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 Related
Jul 15, 2007
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 Related
Aug 13, 2005
Hi
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.
View 1 Replies
View Related
Apr 10, 2006
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");}}
View 2 Replies
View Related
Jan 4, 2007
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
View 2 Replies
View Related
Dec 13, 2007
Hi Guys,
I am trying to automate a basic task using SQL Server 2005 Express.
Currently I have a query script that I run and then save the results as a CSV file. I need to do this on a daily basis and so I am looking to find out how best to go about this. There are a multitude of third party tools that claim to be able to do this - can anyone recommend this or enlighten me of the best way to set up this automation.
All ideas gratefully received!
View 1 Replies
View Related
Sep 12, 2007
Hey Guys need your help please!
we are now on our second week back log...
database file is not full and not limited to growth. As a matter of fact batch transactions are done but our proble is very slow. 28 records has been successfully save after 45 mins. Before it's just 5 minutes. Then some other process are not working. Is there anything that I must do? We have 460 tables in our software using SQL server 2000 and our application is using VB 6.0
View 3 Replies
View Related
Apr 10, 2006
Hello,I use SQL Server 2005 Express and I would liketo save on db of mine...Have I only to save the .mdf and .ldf data fileor I need to stop some service or other programs?Can I use some utility to schedule this?ThanksM.
View 4 Replies
View Related
Oct 25, 2006
My install of SQL Server 2005 runs like a dog. The SQL Management Studio splash screen lasts for 10 minutes, then when the Studio window appears it takes another 5 minutes to initialize.
I have SQL server installed on a Germane Server running Windows Server 2K, SP4. It has quad Xeon 2.8 GHz processors with 2GB RAM. 4 300GB drives in a RAID 5 configuration.
I have created 2 databases which I would like to save, uninstall SQL, then reinstall it. (I didn't install it the first time.)
Then load the 2 databases into the new install.
How do I do this?
View 1 Replies
View Related
Jan 20, 2008
Hi.
I am new to SQL Server management.
I created a new database and also a table names customer. Saved my works.
Want ot know where the SQL database file has been saved because i cant find in the the sql server management folder located in my documents.
Also i tried to connect to that database from vb 2008 but in vain. i just cant see the database.
View 4 Replies
View Related
May 11, 2007
has anyone got any opinions on the pros/cons of storing mp3 files in the database instead of the file system ?
How could this be done ? Would it be a binary data type ?
View 1 Replies
View Related
Aug 8, 2007
Im using MS visual web developer. I have created a website and used the database they set up by using admin tools. One page requires the take the users comment and to save it into the database. I've tried a formview and connected it to the database which worked. the problem is i cannot save whatever the user types into the textbox. {insert query didnt work with this set up }INSERT INTO aspnet_Membership(Comment) VALUES ('CommentTextBox.Text') Error: cannot set userId or to null. and if i make it allow nulls its going to move on to the next column. I would appreciate some help please. Thank you in advance.
View 4 Replies
View Related
Feb 6, 2008
hi
I have two questions:
1. I want a code to save data typed in a textbox during runtime using SQL server database. The database has a table with several colums where i have to reference the necessary column.
2. Can i use a Gridview to enter data during runtime and save the same data to the database? that is, INSERTING data to the database.
View 1 Replies
View Related
Dec 1, 2005
I'm looking for information that could tell me how to saving picture in a SQL database. The site is build on asp.net 2.0 and c#, and I'm using Visual Web Developer 2005 Express Edition. I would be thankful for some help.
View 1 Replies
View Related
Feb 15, 2006
Hi there,
I have a web page (Visual Studio 2005, Asp.net 2.0) that has a series of textboxes and dropdownlists on it. I want people to be able to enter their information and click submit. When they click the submit button I want their information to save to a Sql Server 2005 database. I am having a lot of trouble finding any information on this topic. If someone could give me some sample code I would really appreciate it.
Thanks
View 2 Replies
View Related
May 19, 2008
I'm using vs2008 programming in the latest vb.net and am pretty new to sql server. I looked up tuts and such to save changes to databases after I understood on how to connect to them get them to display and such. This is my code when I hit the "Save" button. It worked last time I was working on the program, now it doesn't, when I load up the program sometimes (i'm not sure why or under what circumstances) it'll load up the changes I made to the database through the datagrid and saved, but others it won't. What am I doing wrong? Here's my code:
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Try
Me.Validate()
Me.FinancialBindingSource.EndEdit()
Me.FinancialTableAdapter.Update(Me.myDataSet.Financial)
Catch ex As Exception
MsgBox("Update failed")
End Try
End Sub
edit: It saves, but not completely. By that I mean, it'll save, but i'm not sure if it actually saves to the database or not. It will load back up with the data that I modified fine..unless I change any code in the program. Even if I just add a comment, the data reloads with the original data. However, if I don't touch code, it'll save my data fine. Why does it do this?
View 1 Replies
View Related
Jul 20, 2005
I have an application that connects and edits a database's tables.My question is, what is the best way to save who did what changes tothis database? I need to be able to display this in the application.The best way I have thought of so far is, to create a new table with'user', 'date', 'table_name', 'primary_key', 'old field_value' and'new_field_value' fields. Then I can save which table row had beenchanged, by which user and on which date.I'm sure that there is a way to do this in SQL Server, but I'm notsure how.Any help would be appriciated.Jagdip
View 1 Replies
View Related
Oct 24, 2006
Using: Compact Framework 1.0 and SQL Server CE 2.0
i want to save an image to my sql server ce 2.0 database on the device.
In the Compact Framework 1.0 the Image class does not have .FromStream method, and the PictureBox class does not .Save method.
Has anyone done this before in SQL CE 2.0 and CF1.0
Thanks
View 1 Replies
View Related
Nov 11, 2006
Hello,
My english is not the best, but i will try my best.
I want to change the saving folder for the database from my systempartition to my datapartition (from c:labla to d:mydata), but i dont know how. I can see the folder but it is in gray font and unchangeable.
Greetings Thomas
View 1 Replies
View Related
Sep 18, 2007
Heres my requirement from a financial analysis im doing...I have just calculated an industry averages on financial ratios...Now i wanna upload this industry average to the system...so that I can compare it to the individual companies' averages after calculating a particular company's average; meaning i wanna be able to call the industry average of a particular ratio (eg Current Ratio) after calculating a company's corresponding ratio...Is there a code fragment i can use for this ?? Thanks in advance...Adam
View 1 Replies
View Related
Jan 3, 2005
i need to know how can i store my word document into Sql server Database
what data type ?
how can i implenet this using ASP.net
View 3 Replies
View Related
Dec 15, 2007
i work on sql server 2005 at home and have created a database with several tables and dabase diagram , now how do i transfer it to sql server 2000 which i work on at work ,
can somebody point me in the right direction in which this is done
any hlp appreciated
View 1 Replies
View Related
Aug 7, 2007
Hi
Would anyone be able to tell me how to save a database and all its objects e.g. Procedures and views etc. onto a CD and then open it on another SQL Server? For SQL Server 7.0 and 2000.
Thanks
View 2 Replies
View Related
Apr 8, 2008
Hi all,
I have a replicated table with a column which is used to store sound files - it is of type varbinary(MAX).
What is the best way to store a file from the filesystem inside this column on the PDA side (i.e. inside SQL Server CE) without loading the whole file into the PDA's memory, i.e. using some sort of buffering?
On full SQL Server 2005 I make use of UPDATE.WRITE() to save buffers inside the column - is there an alternative to this on SQL Server CE? Can anyone provide sample code / point me to samples that deal with SQL Server CE & BLOBs.
Thanks for your help!
View 11 Replies
View Related
Oct 19, 2006
can some one help me. im using visual studio.net 2005. its a web application.i have a database with attribute name logo. so i want to upload an image and save it into the database and than display it into the image box to preview how the image looks like.can some one please help me as i am very new in using C# codes and visual studio.net 2005
View 5 Replies
View Related
Jan 2, 2007
hi
I have binary files inside my database. and user should have the opportunity to download them from database to his computer. I don't want to retrive and save the file into the server first and then let him to download. is it posible???
thank you in advance
regards
View 3 Replies
View Related
Oct 13, 2007
I am trying to save an uploaded picture filepath to a sql database record. The record that the filepath will be saved to will be the record determined by the logged in userid. I get an error stating Object not set to an instance of an object. This is my code for when the upload button is hitProtected Sub uploadbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadbutton.Click
If UploadTest.HasFile = False Then
' No file uploaded!
UploadDetails.Text = "Please first select a file to upload..."
Else
' Display the uploaded file's detailsUploadDetails.Text = String.Format( _
"Uploaded file: {0}<br />" & _"File size (in bytes): {1:N0}<br />" & _"Content-type: {2}", _
UploadTest.FileName, _
UploadTest.FileBytes.Length, _
UploadTest.PostedFile.ContentType)
' Save the fileDim filePath As String = Server.MapPath("~/ProfilePictures/" & UploadTest.FileName)
UploadTest.SaveAs(filePath)Dim datasources1 As New SqlDataSourcedatasources1.ConnectionString = ConfigurationManager.ConnectionStrings("aspnetdb_connection").ToString()
datasources1.UpdateCommandType = SqlDataSourceCommandType.Text
Dim myUserID As String = Membership.GetUser().ProviderUserKey.ToStringdatasources1.UpdateParameters("userid").DefaultValue = myUserID
datasources1.UpdateCommand = "UPDATE into profile_details (pic) VALUES (@filepath) WHERE ([UserId] = @UserId)"
End If
End Sub
Any ideas on what i need to do to fix this?
View 5 Replies
View Related
Dec 6, 2005
Hi,Using VB.net I have created a custom object (hope my terminology is correct here), it’s just a class that defines a few string, integer, and hash table variables. After creating an instance of this class and populating it with data I need to be able to store this instance of my object in a sql server data base table. How do I do this? I saw an article that used the image data type to achieve this (code was in java unfortunately) is this the correct approach. Could you please give me some code examples
Thanks
View 1 Replies
View Related
Feb 22, 2007
Hi,I'm using VS2005 and I'm trying to link the C# windows form to MSSQL.I used BindingNavigator Control to read the data. After that I addsqlcommand and sqldataadapter to send the data to the database. Mycode is thissqlDataAdapter1. InsertCommand. CommandText ="INSERT INTO SUDENT (" +"S_ID, S_NAME, S_ADDRESS, S_PHONE" +") VALUES ('" +S_IDComboBox. Text + "', '" +S_NAMETextBox. Text + "', '" +S_ADDRESSTextBox. Text + "', '" +S_PHONETextBox. Text + "')";sqlDataAdapter1. InsertCommand. ExecuteNonQuery( );It gave me this error"NulleferenceExcept ion was Unhandled"and " Object refrence not set toan instance of an object" so I add this linesqlCommand1 = ("INSERT INTO STUDENT (S_ID,S_NAME, S_ADDRESS, S_PHONE)VALUES (@S_ID,@S_NAME, @S_ADDRESS, @S_PHONE) " ,sqlConnection1) ;Then it gave me some stupid error. By the way it didn't make a newobject of SqlCommand although I tired ....So can u help me to solve my problem ? Thank you
View 1 Replies
View Related
Nov 28, 2006
I am brand new to SQL. Have limited coding experience w/ Visual Basic and database ops w/ Access.
I have come into possession of a SQL 2005 database. The problem is that the designer tried to re-invent the wheel and code a very very poor LMS back end for tracking and reporting. I would like, if possible, to save the database and as far as I am aware - should be able to import into Access and generate statistics and reports to my hearts content.
I have tried w/out success to save the database going through SQL Server Management Studio Express.
Any help or information that could be provided would be appreciated. Any additional information that I can provide, please let me know.
Thanks - Will
View 3 Replies
View Related