Click here to Skip to main content
14,768,114 members
Home » Discussions » Visual Basic
   

Visual Basic

 
GeneralRe: open a new form from previous one Pin
Christian Graus29-Apr-07 21:59
protectorChristian Graus29-Apr-07 21:59 
GeneralRe: open a new form from previous one Pin
A*****29-Apr-07 22:16
MemberA*****29-Apr-07 22:16 
GeneralRe: open a new form from previous one Pin
Dave Kreskowiak30-Apr-07 9:13
mveDave Kreskowiak30-Apr-07 9:13 
QuestionHow to open only one instance of an application? Pin
just3ala229-Apr-07 21:18
Memberjust3ala229-Apr-07 21:18 
AnswerRe: How to open only one instance of an application? Pin
just3ala229-Apr-07 21:51
Memberjust3ala229-Apr-07 21:51 
AnswerRe: How to open only one instance of an application? Pin
Steven J Jowett30-Apr-07 1:42
MemberSteven J Jowett30-Apr-07 1:42 
GeneralRe: How to open only one instance of an application? Pin
just3ala230-Apr-07 4:41
Memberjust3ala230-Apr-07 4:41 
QuestionProblem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 21:09
MemberJats_4ru29-Apr-07 21:09 
I am developing a project to import a CSV format file and iinserting the data to Access Database.
After importing the data to a datagridview, i am inserting the data in datagridview to Database using a dataset(ds).
The insertion has to take place in two different tables (Candidate and Test).

The below code is what i am using for to serve the purpose.

'Updating Candidate table working properly
Private Sub ibt()
Dim i, id As Integer
Try
strSQL = "select ECCMID from Candidate where ECCMID=(select max(ECCMID) from Candidate)"
cnSQL = New OleDbConnection(ConnectionString)
cnSQL.Open()
cmSQL = New OleDbCommand(strSQL, cnSQL)
drSQL = cmSQL.ExecuteReader()
If drSQL.Read() Then
id = drSQL.Item("ECCMID") + 1
ph = id
Else
id = 7001
ph = id
End If

For i = 0 To ((ds.Tables("CInfo").Rows.Count) - 1)
strSQL = "insert into Candidate(ECCMID,CFName,CMName,CLName,MA1,MA2,MA3,City,State,Zipcode,Country) values(" & id & ",'" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(0) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(1) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(2) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(3) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(4) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(5) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(6) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(7) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(8) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(9) & "')"
cnSQL = New OleDbConnection(ConnectionString)
cnSQL.Open()
cmSQL = New OleDbCommand(strSQL, cnSQL)
cmSQL.ExecuteNonQuery()
id = id + 1
Next

drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
Catch Exp As OleDbException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "Oledb Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub

'Updating Test table its generating an error as "Unspecified error" after certain records are inserted. The error can struck at 2 record or at 90th record or at any point.
Private Sub ibt1()
Dim i, id1 As Integer
Dim s As String = "Null"
id1 = ph
Try
For i = 0 To ((ds.Tables("CInfo").Rows.Count) - 1)
s = IIf(IsDBNull(ds.Tables("CInfo").Rows(i).ItemArray.GetValue(11)), Nothing, ds.Tables("CInfo").Rows(i).ItemArray.GetValue(11))
strSQL = "insert into Test(ECCMID,TestID,Title,Series,TestD,Result) values(" & id1 & "," & 1 & ",'" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(10) & "','" & CInt(s) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(12) & "','" & ds.Tables("CInfo").Rows(i).ItemArray.GetValue(13) & "')"
cnSQL = New OleDbConnection(ConnectionString)
cnSQL.Open()
cmSQL = New OleDbCommand(strSQL, cnSQL)
cmSQL.ExecuteNonQuery()
id1 = id1 + 1
Next

Main.StatusLabel1.Text = "Records are successfully inserted"
MsgBox("The * file data has been imported to the database", MsgBoxStyle.Information, "Information")

drSQL.Close()
cnSQL.Close()
cmSQL.Dispose()
Catch Exp As OleDbException
MsgBox(Exp.Message, MsgBoxStyle.Critical, "Oledb Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub

The problem is in the second fuction.
While Updating Test table its generating an error as "Unspecified error" after certain records are inserted. The error can struck at 2 record or at 90th record or at any point, no specific location.

Can any body help me with it, i just need a clue why the error is generated, Any problem with the code?

Plz help...

Jats

AnswerRe: Problem while data insertion in Access - Plz need help Pin
Christian Graus29-Apr-07 22:00
protectorChristian Graus29-Apr-07 22:00 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 22:08
MemberJats_4ru29-Apr-07 22:08 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Colin Angus Mackay30-Apr-07 6:24
MemberColin Angus Mackay30-Apr-07 6:24 
QuestionHow to read volume label Pin
re infecta29-Apr-07 20:24
Memberre infecta29-Apr-07 20:24 
AnswerRe: How to read volume label Pin
A*****29-Apr-07 20:42
MemberA*****29-Apr-07 20:42 
QuestionRunning a function every hour Pin
re infecta29-Apr-07 20:22
Memberre infecta29-Apr-07 20:22 
AnswerRe: Running a function every hour Pin
Dave Kreskowiak30-Apr-07 9:09
mveDave Kreskowiak30-Apr-07 9:09 
Questioncsv file reading Problem Pin
virendra_00729-Apr-07 20:08
Membervirendra_00729-Apr-07 20:08 
AnswerRe: csv file reading Problem Pin
Dave Kreskowiak30-Apr-07 9:08
mveDave Kreskowiak30-Apr-07 9:08 
GeneralRe: csv file reading Problem Pin
virendra_0072-May-07 0:51
Membervirendra_0072-May-07 0:51 
Questioncombo box Pin
Patelgarha29-Apr-07 19:50
MemberPatelgarha29-Apr-07 19:50 
AnswerRe: combo box Pin
Christian Graus29-Apr-07 19:57
protectorChristian Graus29-Apr-07 19:57 
AnswerRe: combo box Pin
Sonia Gupta29-Apr-07 20:29
MemberSonia Gupta29-Apr-07 20:29 
QuestionEmbedding Javascript in ASP Pin
jase7629-Apr-07 19:11
Memberjase7629-Apr-07 19:11 
AnswerRe: Embedding Javascript in ASP Pin
Christian Graus29-Apr-07 19:21
protectorChristian Graus29-Apr-07 19:21 
GeneralRe: Embedding Javascript in ASP Pin
jase7629-Apr-07 21:27
Memberjase7629-Apr-07 21:27 
QuestionHOw to use Shared Event Handler? Pin
braleping29-Apr-07 17:26
Memberbraleping29-Apr-07 17:26 

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.