473,382 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Insert Date into datagrid

18
Does anyone know how to insert date into vb.net datagrid by using INSERT INTO command?

From the code below, the error message is in cmd.ExecuteNonQuery() line.
Here is the error message:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll



Dim today As Date
today = Date.Today

Dim str As String = "Provider=Microsoft.Jet.Oledb.4.0;Data source=ALK.mdb"
Dim conn As oledbconnection = New oledbconnection(str)

'Open connection
conn.Open()

Dim strCmd As String = "INSERT INTO tableTempTransaction(transaction_Date, item_Name) VALUES('today', '" & txtItemDesc.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(strCmd, conn)

'Execute command
cmd.ExecuteNonQuery()

'Close connection
conn.Close()

'DsTempTransaction11.Clear()
OleDbDataAdapter1.Fill(DsTempTransaction11)
Jul 27 '07 #1
1 2118
yzlin04
18
Does anyone know how to insert date into vb.net datagrid by using INSERT INTO command?

From the code below, the error message is in cmd.ExecuteNonQuery() line.
Here is the error message:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll



Dim today As Date
today = Date.Today

Dim str As String = "Provider=Microsoft.Jet.Oledb.4.0;Data source=ALK.mdb"
Dim conn As oledbconnection = New oledbconnection(str)

'Open connection
conn.Open()

Dim strCmd As String = "INSERT INTO tableTempTransaction(transaction_Date, item_Name) VALUES('today', '" & txtItemDesc.Text & "')"
Dim cmd As OleDbCommand = New OleDbCommand(strCmd, conn)

'Execute command
cmd.ExecuteNonQuery()

'Close connection
conn.Close()

'DsTempTransaction11.Clear()
OleDbDataAdapter1.Fill(DsTempTransaction11)

I can insert the date into the datagrid already. Thanks
Jul 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Christopher | last post by:
I AM GETTING A SYSTEM.DATA.SQLCLIENT.SQLEXCEPTION ERROR WHEN ATTEMPTING TO INSERT DATA INTO A SINGLE TABLE THROUGH A GRID //If this is due to a spelling error, i will //inflict a ritual...
5
by: SSP | last post by:
Dear ASP.NETers, How would I insert multiple rows of data from a web form? Are there any tute's and stuff around. Couldn't find any myself. Thanks in advance. SSP
1
by: tshad | last post by:
I can't seem to get insert into a DataGrid to work. I am using an example from the net and made changes to work on my computer. The grid comes up fine. The edit boxes in the footer are there. ...
0
by: Tim::.. | last post by:
Can someone please help! I'm trying to write an insert statement for a complex datagrid! The database consists of the following data structure! ..tblContent PageID PK ModDate Description...
2
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error from the code below! Error: INSERT statement conflicted with COLUMN FOREIGN KEY constraint...
4
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as...
1
by: glenn | last post by:
Hi folks, I am using an Access database, VB.NET and ADO.NET working with a DataGrid control. MY datagrid table has both a date_sent and a date_ans field. When I Insert a record in my SQL...
0
by: simchajoy2000 | last post by:
Hi, I am experiencing a strange problem when inserting rows in a datatable that is attached to a datagrid. I have made it so that when the user right clicks on a row the context menu item...
5
by: Me LK | last post by:
I need to add a line to choose a size into a dropdown . Since I have the dropdown nested inside a datagrid this is not working.When a page displays there are several rows of dropdowns but only the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.