Click here to Skip to main content
15,910,121 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to import data by character wise from excel to sql server Pin
Paul Conrad30-Dec-07 10:47
professionalPaul Conrad30-Dec-07 10:47 
GeneralDataGridView: Add combobox Pin
nishkarsh_k25-Dec-07 23:05
nishkarsh_k25-Dec-07 23:05 
GeneralRe: DataGridView: Add combobox Pin
helelark12326-Dec-07 5:01
helelark12326-Dec-07 5:01 
GeneralRe: DataGridView: Add combobox Pin
nishkarsh_k26-Dec-07 17:33
nishkarsh_k26-Dec-07 17:33 
GeneralRe: DataGridView: Add combobox Pin
helelark12326-Dec-07 18:54
helelark12326-Dec-07 18:54 
GeneralRe: DataGridView: Add combobox Pin
nishkarsh_k26-Dec-07 23:19
nishkarsh_k26-Dec-07 23:19 
QuestionHow to save data from datatable to database using vb.net Pin
Eunice (VB junior)25-Dec-07 21:15
Eunice (VB junior)25-Dec-07 21:15 
AnswerRe: How to save data from datatable to database using vb.net Pin
Dave Kreskowiak26-Dec-07 8:28
mveDave Kreskowiak26-Dec-07 8:28 
A DataGrid is used to show and edit the data in a DataSource, such as a DataTable or DataSet. You don't go from DataTable to DataGrid to database. You go from DataGrid - which shows and edits a DataTable/DataSet - which synchronizes changes with a Database.

From what you've posted, your code is pretty much spaghetti.

If you're adding records to an existing database, I'd start by creating a DataSet and DataAdapter with the proper SQL statement to retrieve the fields from the table that you're going to manipulate. Use it's FillSchema method to create a new DataTable object in your DataSet object. This will automatically setup your DataTable for your, mapping the columns in the database to the columns in the DataTable using the proper data types.

Then, you use a CommandBuilder (SqlCommandBuilder, OleDbCommandBuilder, ...) on the DataAdapter to create the SQL UPDATE, INSERT, and DELETE commands for the DataAdatper.

Then bind the DataGrid to that DataTable, make your changes, then use the DataAdapter's Update method to write the changes back to the database.



A guide to posting questions on CodeProject[^]



Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007




Generalparallel port in VB .Net 2008 Pin
meki_211825-Dec-07 20:19
meki_211825-Dec-07 20:19 
GeneralRe: parallel port in VB .Net 2008 Pin
Dave Kreskowiak26-Dec-07 3:40
mveDave Kreskowiak26-Dec-07 3:40 
Questionhow to collect ip address of the systems in LAN Pin
Prakash_Mishra25-Dec-07 20:00
Prakash_Mishra25-Dec-07 20:00 
AnswerRe: how to collect ip address of the systems in LAN Pin
Dave Kreskowiak26-Dec-07 3:36
mveDave Kreskowiak26-Dec-07 3:36 
QuestionProgressBar (Vista) How do I: Split a PB to a few internal colors with different colors, and merging a Percentage indicator label within it? Pin
Shimmy Weitzhandler25-Dec-07 17:00
Shimmy Weitzhandler25-Dec-07 17:00 
GeneralRe: ProgressBar (Vista) How do I: Split a PB to a few internal colors with different colors, and merging a Percentage indicator label within it? Pin
Dave Kreskowiak26-Dec-07 2:10
mveDave Kreskowiak26-Dec-07 2:10 
GeneralRe: ProgressBar (Vista) How do I: Split a PB to a few internal colors with different colors, and merging a Percentage indicator label within it? Pin
Shimmy Weitzhandler26-Dec-07 14:56
Shimmy Weitzhandler26-Dec-07 14:56 
GeneralRe: ProgressBar (Vista) How do I: Split a PB to a few internal colors with different colors, and merging a Percentage indicator label within it? Pin
Dave Kreskowiak27-Dec-07 5:04
mveDave Kreskowiak27-Dec-07 5:04 
GeneralRe: ProgressBar (Vista) How do I: Split a PB to a few internal colors with different colors, and merging a Percentage indicator label within it? Pin
Shimmy Weitzhandler30-Dec-07 8:57
Shimmy Weitzhandler30-Dec-07 8:57 
QuestionCan a Label.BackColor be transparent? Pin
Shimmy Weitzhandler25-Dec-07 16:48
Shimmy Weitzhandler25-Dec-07 16:48 
GeneralRe: Can a Label.BackColor be transparent? Pin
Nilesh Hapse25-Dec-07 18:49
Nilesh Hapse25-Dec-07 18:49 
GeneralRe: Can a Label.BackColor be transparent? Pin
Shimmy Weitzhandler26-Dec-07 15:01
Shimmy Weitzhandler26-Dec-07 15:01 
GeneralLineInput LineFeed problem Pin
MohammadAmiry24-Dec-07 21:23
MohammadAmiry24-Dec-07 21:23 
GeneralRe: LineInput LineFeed problem Pin
Dave Kreskowiak26-Dec-07 6:14
mveDave Kreskowiak26-Dec-07 6:14 
Generalarrary of button Pin
break_day24-Dec-07 4:06
break_day24-Dec-07 4:06 
GeneralRe: arrary of button Pin
darkelv24-Dec-07 4:34
darkelv24-Dec-07 4:34 
GeneralRe: arrary of button Pin
DigiOz Multimedia24-Dec-07 6:32
DigiOz Multimedia24-Dec-07 6:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.