Did anyone manage to take a look? I agree that the code is fine - tried it in another databound Datagrid of mine and it worked fine.
There's gotta be something preventing it either in the designer or in code!
Printable View
Did anyone manage to take a look? I agree that the code is fine - tried it in another databound Datagrid of mine and it worked fine.
There's gotta be something preventing it either in the designer or in code!
I have sorted it. All I did was change the Property Readonly from True to False in the Datagridview designer and now it works!
Surely that shouldn't have been affecting the ComboBoxColumn??
That kind of makes sense - if the entire grid is read-only, then you won't be allowed to change the value of the combo, so it won't drop down.
It's doing something else strange now - when I click save it says that:
This is the column I was having trouble with before. I have tried both selecting values for each row in the column and also setting:Quote:
Parameter @7 has no default value
but it still comes up with that error. I have also tried:Code:.DefaultCellStyle.NullValue = "0"
but still nothing!Code:DataGridView1.CommitEdit
LOL! It is always the small things that mean big headaches!
I knew it had to be something else :)
I just run your app now ( only started with it now ), and I got a Parameter @13 has no default value, in this section :
Parameter 13 in this case is MeritsCode:If ExcelYear = "10" Then
Dim MyExcelConnection As New System.Data.OleDb.OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\08-09\Year 10 2008-09.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0""")
MyExcelConnection.Open()
With myInsertCommand
.CommandText = "Insert INTO [Sheet1$] ([StudentId],[StudentName],[ClassGrp],[TheDate],[Merits],[Demerits],[Penalty],[Lesson]," + _
"[TeachingGrp],[Staff],[Description],[Action],[MeritType]) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13)"
.CommandType = CommandType.Text
.Connection = MyExcelConnection
For Each Row As DataGridViewRow In DataGridView1.Rows
For Col As Int32 = 1 To Row.Cells.Count
.Parameters.Add(New OleDb.OleDbParameter("@" & Col, OleDb.OleDbType.Char)).Value = CStr(Row.Cells(Col - 1).Value)
Next Col
.ExecuteNonQuery()
.Parameters.Clear()
Next
End With