Click here to Skip to main content
15,905,420 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Updating Gridview on one page from a different page. Pin
N a v a n e e t h29-May-08 17:47
N a v a n e e t h29-May-08 17:47 
QuestionAdd/Remove type control for Web pages? Pin
Josh Martin29-May-08 12:53
Josh Martin29-May-08 12:53 
AnswerRe: Add/Remove type control for Web pages? Pin
Christian Graus29-May-08 13:33
protectorChristian Graus29-May-08 13:33 
GeneralRe: Add/Remove type control for Web pages? Pin
Josh Martin30-May-08 6:40
Josh Martin30-May-08 6:40 
QuestionStoring html Pin
ChrisFarrugia29-May-08 11:21
ChrisFarrugia29-May-08 11:21 
AnswerRe: Storing html Pin
Christian Graus29-May-08 13:34
protectorChristian Graus29-May-08 13:34 
AnswerRe: Storing html Pin
N a v a n e e t h29-May-08 15:39
N a v a n e e t h29-May-08 15:39 
Questiontrouble with tableAdapter.update method Pin
ghazanfarKhan29-May-08 9:48
ghazanfarKhan29-May-08 9:48 
Hi all.



I have written a simple application in vb.net (2.0) that reads data from an excel sheet (previously stored in focus databases) and stores it into a sql server database. I am using typed datasets and table adapters to store the data. I have an "Import" button whose event handler does the following in turn.

1. connect to the excel sheet through an ole db conn

2. read the contents in a while loop using the executeReader() method

3. store the values in variables where necessary conversions and validations are performed.

4. call an insert method in the associated dataset tableAdapter that stores these processed values in the sql db.



This is all working as it should. Now I need to check for existing records before I import the values - Ignore completely if the value is found.

According to msdn, I should be able to use my tableAdapters update method by passing a dataSet/Table/Row(s). So this is how I tried to tackle it.




Legend:

lbf = my DataSet

lbf_COKEnCOLE = the Database table associated with lbf DataSet

GetRecordByIdDateLab = runs the following SQL Query on the data

SELECT *

FROM lbf_COKEnCOLE

WHERE (ORIGINATOR_ID = @ORIGINATOR_ID) AND (SMPL_DTE = @SMPL_DTE) AND (LAB_NUM = @LAB_NUM)

(The actual sql refers to all the columns by names instead of using *)





'Code starts here

Dim tableadapter As New lbfTableAdapters.lbf_COKEnCOLETableAdapter

Dim dataTable As lbf.lbf_COKEnCOLEDataTable = Nothing

'check for existing record by using GetRecordByIdDateLab method

dataTable = tableadapter.GetRecordByIdDateLab(ORIGINATOR_ID, SMPL_DTE, LAB_NUM)

If Not dataTable Is Nothing Then

If dataTable.Rows.Count > 0 Then

If Not dataTable(0).ORIGINATOR_ID = Nothing Then

'Row = dataTable(0)

dataTable(0).TURN = TURN





tableadapter.Update(dataTable) '<<THIS IS WHERE IT CRASHES WITH "A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll

End If





'The following tableAdapter works perfectly whenever the condition is true (for new entries that is)

ElseIf dataTable.Rows.Count = 0 Then

tableadapter.InsertQuery(counter, ORIGINATOR_ID, SMPL_DTE, LAB_NUM, TURN)

End If

End If



****************************************

More details:

I have DataTable under "Watch" and the value for it shows up as "dataTable has not been declared". This ofcourse is misleading because it is, plus intellisense picks it up where I'm updating the column values by referencing them with dataTable(0).columnName

I have been wondering if

dataTable = tableadapter.GetRecordByIdDateLab(ORIGINATOR_ID, SMPL_DTE, LAB_NUM)

does what its supposed to do, ie. return a dataTable with the matching record. I tried to recieve the data in a row but it only allowed it to be saved in a datatable instantiated in this manner. Furthermore, when I read the values read into the datatable, each column value shows up only as lbf_COKEnCOLE.column (something to this effect) in curly braces. Almost everything else thats returned, like index values and what not that I suppose is used to keep the schema of the table has errors in it.

Any suggestions and help would be greatly appreciated!! I am trying to avoid suddenly using command objects when I'm doing everything else through a data Access layer. lastly, I have read and reread this msdn page

http://msdn.microsoft.com/en-us/library/ms233819(VS.80).aspx

and am trying to do everything as shown here, obviously to no avail



All .net people out there, if you would help this awkward programmer, it would be greatly appreciated! Thanks

~Ghazanfar
QuestionAJAX problem - deleting table rows Pin
prezident29-May-08 7:04
prezident29-May-08 7:04 
QuestionDocumentation for style sheets vs. web control declarative attributes Pin
Christopher Duncan29-May-08 5:45
Christopher Duncan29-May-08 5:45 
AnswerRe: Documentation for style sheets vs. web control declarative attributes Pin
led mike29-May-08 6:06
led mike29-May-08 6:06 
GeneralRe: Documentation for style sheets vs. web control declarative attributes Pin
Christopher Duncan29-May-08 6:34
Christopher Duncan29-May-08 6:34 
GeneralRe: Documentation for style sheets vs. web control declarative attributes Pin
led mike29-May-08 7:57
led mike29-May-08 7:57 
Questionhow to set a error path to a file in asp.net page Pin
trannguyen8629-May-08 5:45
trannguyen8629-May-08 5:45 
AnswerRe: how to set a error path to a file in asp.net page Pin
N a v a n e e t h29-May-08 7:19
N a v a n e e t h29-May-08 7:19 
AnswerRe: how to set a error path to a file in asp.net page Pin
HelloRedStone29-May-08 17:35
HelloRedStone29-May-08 17:35 
GeneralRe: how to set a error path to a file in asp.net page Pin
trannguyen8629-May-08 20:20
trannguyen8629-May-08 20:20 
QuestionAsp.net uniqueURL problem Pin
maithili_koli29-May-08 4:38
maithili_koli29-May-08 4:38 
QuestionHow can I detect if Application is running under high trust level Pin
Nadia Monalisa29-May-08 3:37
Nadia Monalisa29-May-08 3:37 
AnswerRe: How can I detect if Application is running under high trust level Pin
led mike29-May-08 4:40
led mike29-May-08 4:40 
GeneralRe: How can I detect if Application is running under high trust level Pin
Nadia Monalisa29-May-08 5:34
Nadia Monalisa29-May-08 5:34 
QuestionHow can i create an aspx page dynamically Pin
Satish - Developer29-May-08 3:04
Satish - Developer29-May-08 3:04 
AnswerRe: How can i create an aspx page dynamically Pin
Mogaambo29-May-08 3:07
Mogaambo29-May-08 3:07 
GeneralRe: How can i create an aspx page dynamically Pin
Satish - Developer29-May-08 3:11
Satish - Developer29-May-08 3:11 
GeneralRe: How can i create an aspx page dynamically Pin
Satish - Developer29-May-08 3:12
Satish - Developer29-May-08 3:12 

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.