Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #11 (permalink)  
Old March 12th, 2009, 05:50 PM
Authorized User
 
Join Date: Mar 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
even quicker way to solve it.. load the file in excel, copy all the cells, open the table in VS express, paste the cells :)
That would be fantastic if I could do that, but I can't get it to work. It just copies the first cell. I tried copying from the text file as well as the excel file. Am I missing something?
  #12 (permalink)  
Old March 12th, 2009, 06:21 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Don't put the cursor on the first cell of the destination table, select all the row and it will work. ;) (select the row pressing on the gray area of the left, where the little arrow is, then paste there)
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
  #13 (permalink)  
Old March 13th, 2009, 01:36 AM
Authorized User
 
Join Date: Mar 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
Don't put the cursor on the first cell of the destination table, select all the row and it will work. ;) (select the row pressing on the gray area of the left, where the little arrow is, then paste there)
Still didn't work. I thought it seemed too easy
  #14 (permalink)  
Old March 13th, 2009, 01:55 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I'm not getting what's happening here. I've never hear of being able to "paste" a column of values into a SQL Server table. That's certainly a new one on me...
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #15 (permalink)  
Old March 13th, 2009, 02:29 AM
Authorized User
 
Join Date: Mar 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
I'm not getting what's happening here. I've never hear of being able to "paste" a column of values into a SQL Server table. That's certainly a new one on me...
I haven't heard of it either, but I was hoping it was true. Oh well...
  #16 (permalink)  
Old March 13th, 2009, 03:00 AM
Authorized User
 
Join Date: Mar 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
Curious, what is your blog address?
Sorry, I missed this reply in our chatter It's called ASP.NET Place, and I only started it a couple weeks ago when I started learning .NET. I figure it'd be a good place to post about interesting articles I find, as well as simple tutorials for things that I have a hard time accomplishing (like this).
  #17 (permalink)  
Old March 13th, 2009, 08:24 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Rush and lee.. I tried that, but on an MDB (but I'm sure you can do it on SQL server too, it's all microsoft!) anyway, the other simple method, is to construct the insert on excel and run them on the query analyzer;)

1- get the data to excel.
2- in the next cell write "insert into YOURTABLE value ('"
3- in the next cell write "')"
4- in the fourth cell concat all the strings (second cell + first cell + third cell)
copy this for all the cells ;)

now copy all the concatenated querys to the query analizer inside VS (bah, where you do the querys). Execute it and VOILA!

There is always a quick solution for everything.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
  #18 (permalink)  
Old March 13th, 2009, 01:44 PM
Authorized User
 
Join Date: Mar 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
...the other simple method, is to construct the insert on excel and run them on the query analyzer;)

1- get the data to excel.
2- in the next cell write "insert into YOURTABLE value ('"
3- in the next cell write "')"
4- in the fourth cell concat all the strings (second cell + first cell + third cell)
copy this for all the cells ;)

now copy all the concatenated querys to the query analizer inside VS (bah, where you do the querys). Execute it and VOILA!
You make things sound so easy (and I'm SURE there has to be an easy solution for this), but I'm just so new to all of this that I don't understand a word you're saying .

I have the data in Excel, but it's only the 2nd column in my DB "Name". I'd like to run some kind of action to create a new record (so the primary key generates an "Id" for it), inserts the value from my text file into the second column ("Name"), and leaves the third column ("Category") blank (which I'll fill in later once I get my dropdownlist box binding correctly).

I guess I'm not clear on a couple things you've said:
  1. Where do I write "insert into YOURTABLE value ("? Is that in a table cell, a SQL statement, or somewhere else?
  2. Is "VALUE" actually that word, or should that be something else?
  3. What about for ")" or the concatenation string you mentioned? Where does that go and why are there three values in there when all I need & have is one value to insert?
  4. "Copy this for all the cell." Do you mean once I have this concatenation statement created, copy & paste it manually into the 250 rows of my table? If so, I might as well just hand-enter all my values.
Again, I'm probably misunderstanding something you've said, and I apologize. This just seems like a kind of function MS would have built into VWD/VS or their database editor to make it super easy and it's turning out to be a nightmare.
  #19 (permalink)  
Old March 13th, 2009, 02:13 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by gbianchi View Post
Rush and lee.. I tried that, but on an MDB (but I'm sure you can do it on SQL server too, it's all microsoft!).
An MDB is an file you can open in Access. Of course, if you open a database in Access, then you can paste into it.

However, there is no way you are going to paste a column of values into an MDF. That doesn't make any sense. MDFs are meant to be edited using DDL. There's no such concept as "pasting" data into an MDF.

Quote:
Originally Posted by gbianchi View Post
anyway, the other simple method, is to construct the insert on excel and run them on the query analyzer;)

1- get the data to excel.
2- in the next cell write "insert into YOURTABLE value ('"
3- in the next cell write "')"
4- in the fourth cell concat all the strings (second cell + first cell + third cell)
copy this for all the cells ;)

now copy all the concatenated querys to the query analizer inside VS (bah, where you do the querys). Execute it and VOILA!
Ah yes, I get it. That would work. Never thought of that. That's actually pretty clever Gonz! . And, probably a lot faster than using a file I/O thing like a StreamReader for a one-time procedure.

Although when I get time, I may still do a blog post on reading text files into a table using a StreamReader. In fact, I would probably make it more general by showing how to read character-delimited lines of entire records, so that you could read and insert multiple columns of data instead of just one value per line.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}

Last edited by Lee Dumond; March 13th, 2009 at 02:16 PM.
  #20 (permalink)  
Old March 13th, 2009, 02:15 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Well, you have that build in function capability in SQL, you can really do an import process from a file into a table..

Also you can modify the txt file to do the update for you.

What you need is an insert statement for every row.
(a statement like
Code:
INSERT INTO table1 VALUES ('textvalue')
)

the autonumeric column will fill by itself. My question at this point is, can you just go and get the original db and start again?

There are a lot of ways to do this, but I think you first need to learn a little about SQL to understand how it works. If you are working againts a database, we will not be very helpfull just telling you how to make the SQL. Even further, understanding it a little will help you in the future...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
How to format txt file exported from access table bbqlee Access VBA 1 August 4th, 2006 03:16 PM
txt file generated from SQl BCP nidhigarg9 SQL Server 2000 1 June 16th, 2006 03:16 PM
Import a Comma separated txt file to SQL table arielote C# 2 April 17th, 2006 02:08 AM
Bulk Insert to Sql Server from .txt file avats BOOK: Beginning VB.NET Databases 1 June 3rd, 2005 05:44 AM



All times are GMT -4. The time now is 03:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.