Click here to Skip to main content
15,915,792 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: open a new form from previous one Pin
Christian Graus29-Apr-07 20:59
protectorChristian Graus29-Apr-07 20:59 
GeneralRe: open a new form from previous one Pin
A*****29-Apr-07 21:16
A*****29-Apr-07 21:16 
GeneralRe: open a new form from previous one Pin
Dave Kreskowiak30-Apr-07 8:13
mveDave Kreskowiak30-Apr-07 8:13 
QuestionHow to open only one instance of an application? Pin
just3ala229-Apr-07 20:18
just3ala229-Apr-07 20:18 
AnswerRe: How to open only one instance of an application? Pin
just3ala229-Apr-07 20:51
just3ala229-Apr-07 20:51 
AnswerRe: How to open only one instance of an application? Pin
Steven J Jowett30-Apr-07 0:42
Steven J Jowett30-Apr-07 0:42 
GeneralRe: How to open only one instance of an application? Pin
just3ala230-Apr-07 3:41
just3ala230-Apr-07 3:41 
QuestionProblem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 20:09
Jats_4ru29-Apr-07 20: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 21:00
protectorChristian Graus29-Apr-07 21:00 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Jats_4ru29-Apr-07 21:08
Jats_4ru29-Apr-07 21:08 
GeneralRe: Problem while data insertion in Access - Plz need help Pin
Colin Angus Mackay30-Apr-07 5:24
Colin Angus Mackay30-Apr-07 5:24 
QuestionHow to read volume label Pin
re infecta29-Apr-07 19:24
re infecta29-Apr-07 19:24 
AnswerRe: How to read volume label Pin
A*****29-Apr-07 19:42
A*****29-Apr-07 19:42 
QuestionRunning a function every hour Pin
re infecta29-Apr-07 19:22
re infecta29-Apr-07 19:22 
AnswerRe: Running a function every hour Pin
Dave Kreskowiak30-Apr-07 8:09
mveDave Kreskowiak30-Apr-07 8:09 
Questioncsv file reading Problem Pin
virendra_00729-Apr-07 19:08
virendra_00729-Apr-07 19:08 
AnswerRe: csv file reading Problem Pin
Dave Kreskowiak30-Apr-07 8:08
mveDave Kreskowiak30-Apr-07 8:08 
GeneralRe: csv file reading Problem Pin
virendra_0071-May-07 23:51
virendra_0071-May-07 23:51 
Questioncombo box Pin
Patelgarha29-Apr-07 18:50
Patelgarha29-Apr-07 18:50 
AnswerRe: combo box Pin
Christian Graus29-Apr-07 18:57
protectorChristian Graus29-Apr-07 18:57 
AnswerRe: combo box Pin
Sonia Gupta29-Apr-07 19:29
Sonia Gupta29-Apr-07 19:29 
QuestionEmbedding Javascript in ASP Pin
jase7629-Apr-07 18:11
jase7629-Apr-07 18:11 
AnswerRe: Embedding Javascript in ASP Pin
Christian Graus29-Apr-07 18:21
protectorChristian Graus29-Apr-07 18:21 
GeneralRe: Embedding Javascript in ASP Pin
jase7629-Apr-07 20:27
jase7629-Apr-07 20:27 
QuestionHOw to use Shared Event Handler? Pin
braleping29-Apr-07 16:26
braleping29-Apr-07 16: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.