Click here to Skip to main content
15,901,853 members

Comments by Member 14802172 (Top 5 by date)

Member 14802172 28-Apr-20 16:16pm View    
I'm not quite sure what you mean by my "grid" has no knowledge of any database. I can submit information into my code and edit it. I'm just having trouble figuring out the delete button. I created this application from the ground up. I've had to teach myself most of what you see by watching videos and reading forms. I'm still very new to this. Hence why I asked a question in the first place. If you have better knowledge of what I should be doing please explain so I can learn. It's not the nicest looking code I know that but I'm doing the best I can. Thank you.
Member 14802172 22-Apr-20 14:53pm View    
I figured it out. I do't know why it took me so long. In the CellContentClickevent I had this lblRowID.Text = ReportDataGrid.Rows[rowIndex].Cells[1].Value.ToString();
I had the wrong index it needs to be 0 not 1. I changed it now the program runs correctly.
Is there a way to get the program to refresh after I hit the update button to show in the datagrid?
I have ReportDataGrid.Refresh(); but it only refreshes after I close the application and re open it.
Thank you again for all your help!
Member 14802172 21-Apr-20 15:49pm View    
Yes it's the same query and EntryID is the only int in the column.
This is what it says next to the lblRowID.Text System.Windows.Forms.Label, Text: 4/21/2020 12:26:00 PM}
This error System.Data.SqlClient.SqlException: 'Conversion failed when converting the nvarchar value '4/21/2020 12:26:00 PM' to data type int.'
is still appearing next to the cmd.ExecuteNonQuery();
I don't understand why it's trying to convert.
Member 14802172 21-Apr-20 13:42pm View    
So I think I fixed that issue but now i'm getting this error System.Data.SqlClient.SqlException: 'Conversion failed when converting the nvarchar value '4/21/2020 12:26:00 PM' to data type int.'

I don't know why it would try to convert that. When I edit the selected column it should let me update the text, click the update button and replace what was orginally in that column with the updated text and smalldatetime.

I'm sorry I'm so much trouble. I've never worked with anything like this before and I'm having to create this entire project myself from the ground up. I'm learning as I go. Thank you for your help.
Member 14802172 21-Apr-20 11:53am View    
So I keep getting the same error everytime System.Data.SqlClient.SqlException: 'Invalid column name 'EntryID'.'
This is my table in design view:
CREATE TABLE [dbo].[Database_tbl] (
[EntryID] INT IDENTITY (1, 1) NOT NULL,
[EntryDate] SMALLDATETIME NOT NULL,
[ReportText] VARCHAR (255) NULL,
PRIMARY KEY CLUSTERED ([EntryID] ASC)
);
So the EntryID is in fact there but I'm getting this error and not sure why..