473,804 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert Date into datagrid

18 New Member
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.ExecuteNonQ uery() line.
Here is the error message:
An unhandled exception of type 'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll



Dim today As Date
today = Date.Today

Dim str As String = "Provider=Micro soft.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 tableTempTransa ction(transacti on_Date, item_Name) VALUES('today', '" & txtItemDesc.Tex t & "')"
Dim cmd As OleDbCommand = New OleDbCommand(st rCmd, conn)

'Execute command
cmd.ExecuteNonQ uery()

'Close connection
conn.Close()

'DsTempTransact ion11.Clear()
OleDbDataAdapte r1.Fill(DsTempT ransaction11)
Jul 27 '07 #1
1 2149
yzlin04
18 New Member
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.ExecuteNonQ uery() line.
Here is the error message:
An unhandled exception of type 'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll



Dim today As Date
today = Date.Today

Dim str As String = "Provider=Micro soft.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 tableTempTransa ction(transacti on_Date, item_Name) VALUES('today', '" & txtItemDesc.Tex t & "')"
Dim cmd As OleDbCommand = New OleDbCommand(st rCmd, conn)

'Execute command
cmd.ExecuteNonQ uery()

'Close connection
conn.Close()

'DsTempTransact ion11.Clear()
OleDbDataAdapte r1.Fill(DsTempT ransaction11)

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
2209
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 beating upon myself !!!!!!!!!!!! TABLE SCRIPT
5
7045
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
1686
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. But when I press the "insert" link, it never seems to go to the DataGrid1_ItemCommand routine. ************************************************************************************** <%@ Page Language="vb" trace="true" debug="true" %> <%@ Import...
0
1191
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 Title ..tblOffice
2
12965
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 'FK_tblOfficePageContent_tblPageContent'. The conflict occurred in database 'CPNCMS', table 'tblPageContent', column 'pageID'. The statement has been terminated. I cant seem to see why I keep getting an error when I do the insert!
4
9638
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 '07-Mar-05' the expression {..:dd-MMM-yy} works OK Second question, does anyone know hwo to return a date from SQL server in the format '07-Mar-05', as this would be a workaround. At the moment I'm using CONVERT(varchar(12),columnname,6 ) to...
1
3089
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 statement, I insert a date_sent but I need to insert a blank date_ans field. date_sent is the date when a question was sent to a group from a web form and date_ans is the date when a question was answered.
0
951
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 "Insert Row" pops up. The event handler code for when they click on this menu item is as follows: Private Sub Insert_Row(ByVal sender As Object, ByVal e As System.EventArgs) Dim tbl As DataTable = New DataTable
5
5483
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 top dropdown has the option added. The others do not. I am using the following code Dim ddlPsize As DropDownList ddlPsize = (itemInfo.Items(0).FindControl("ddlsizes")) ddlPsize.Items.Insert(0, "Choose a Size")
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.