To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Oct 7th, 2006, 12:57 PM   #1
Desolator144
Hyperactive Member
 
Join Date: Oct 05
Posts: 256
Desolator144 has a little shameful behaviour in the past
[2005] Setting table specs on a table I made in code

I want to create a datatable to hold test results from a testing program and I'm adding rows like this:

Dim NewRow As DataRow
NewRow = tblUserAnswers.Rows.Add
NewRow.Item(0) = m_intUserId
etc

which I'm not exactly sure is going to work anyway but how do I set the number of columns and their datatypes to match the Results table in the actual database so that I can send it to the database later (btw is there even a way to do that?) and it won't give me a bunch of datatype mismatch errors or number of columns errors or something. Or do I even have to do that at all?
__________________
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature
Desolator144 is offline   Reply With Quote
Old Oct 7th, 2006, 06:02 PM   #2
jmcilhinney
.NUT
 
jmcilhinney's Avatar
 
Join Date: May 05
Location: Sydney, Australia
Posts: 61,543
jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)
Re: [2005] Setting table specs on a table I made in code

VB Code:
  1. Dim dt As New DataTable
  2. 'Add two columns.
  3. dt.Columns.Add("ID", GetType(Integer))
  4. dt.Columns.Add("Name" GetType(String))
  5. Dim dr As DataRow
  6. 'Add five rows.
  7. For i As Integer = 1 To 5
  8.     dr = dt.NewRow()
  9.     dr("ID") = i
  10.     dr("Name") = "Name " & i
  11.     dt.Rows.Add(dr)
  12. Next i
__________________

2007-2010

Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (Nullable Data Extensions *NEW*) (Serial Code TextBox *NEW*) | C# (ForumAccount has translated some of my VB submissions to C#)
My Blog: Defining and Raising Custom Events | Using Parameters in ADO.NET | Keyboard Events *NEW*
jmcilhinney is online now   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:27 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.