Click here to Skip to main content
15,918,889 members
Home / Discussions / Database
   

Database

 
AnswerRe: ADO.NET Update / delete without primary keys Pin
l a u r e n21-Oct-05 15:06
l a u r e n21-Oct-05 15:06 
GeneralRe: ADO.NET Update / delete without primary keys Pin
Jasonc22124-Oct-05 12:37
Jasonc22124-Oct-05 12:37 
QuestionSQL connection in servicedcomponents Pin
eliprand14-Oct-05 5:43
eliprand14-Oct-05 5:43 
AnswerRe: SQL connection in servicedcomponents Pin
eliprand14-Oct-05 6:08
eliprand14-Oct-05 6:08 
QuestionHow does Oracle support unicode text? Pin
Xiangyang Liu 刘向阳14-Oct-05 5:35
Xiangyang Liu 刘向阳14-Oct-05 5:35 
AnswerRe: How does Oracle support unicode text? Pin
DiWa14-Oct-05 19:30
DiWa14-Oct-05 19:30 
GeneralRe: How does Oracle support unicode text? Pin
Xiangyang Liu 刘向阳14-Oct-05 19:50
Xiangyang Liu 刘向阳14-Oct-05 19:50 
QuestionConnection String Pin
kenexcelon13-Oct-05 14:27
kenexcelon13-Oct-05 14:27 
AnswerRe: Connection String Pin
Mike Dimmick14-Oct-05 4:42
Mike Dimmick14-Oct-05 4:42 
GeneralRe: Connection String Pin
Anonymous14-Oct-05 15:32
Anonymous14-Oct-05 15:32 
QuestionOPENXML and ntext problem Pin
Luke Murray13-Oct-05 13:44
Luke Murray13-Oct-05 13:44 
QuestionListBox Display Member Pin
kenexcelon13-Oct-05 7:49
kenexcelon13-Oct-05 7:49 
AnswerRe: ListBox Display Member Pin
-Dr_X-13-Oct-05 8:44
-Dr_X-13-Oct-05 8:44 
QuestionError: JZooL & JZ006 What do I do? Pin
Crystal A13-Oct-05 3:27
sussCrystal A13-Oct-05 3:27 
AnswerRe: Error: JZooL & JZ006 What do I do? Pin
Mike Dimmick14-Oct-05 5:01
Mike Dimmick14-Oct-05 5:01 
QuestionSyntax error converting the nvarchar value 'INSERT INTO.... Pin
Mahantesh_Hongal12-Oct-05 23:25
Mahantesh_Hongal12-Oct-05 23:25 
AnswerRe: Syntax error converting the nvarchar value 'INSERT INTO.... Pin
under281113-Oct-05 2:08
under281113-Oct-05 2:08 
GeneralRe: Syntax error converting the nvarchar value 'INSERT INTO.... Pin
Mahantesh_Hongal13-Oct-05 2:11
Mahantesh_Hongal13-Oct-05 2:11 
GeneralRe: Syntax error converting the nvarchar value 'INSERT INTO.... Pin
Edbert P13-Oct-05 17:39
Edbert P13-Oct-05 17:39 
GeneralRe: Syntax error converting the nvarchar value 'INSERT INTO.... Pin
Anonymous13-Oct-05 18:35
Anonymous13-Oct-05 18:35 
GeneralRe: Syntax error converting the nvarchar value 'INSERT INTO.... Pin
Edbert P13-Oct-05 19:08
Edbert P13-Oct-05 19:08 
QuestionInsert to SQL Error Pin
PAEC12-Oct-05 7:00
PAEC12-Oct-05 7:00 
Can someone tell me what is wrong with the following Insert Function?
Thanks...


The TABLE Properties
CreatedBy int 4 NULLS
D'Oh! | :doh:

The CODE
Dim intUser As Integer

Public Function InsertFiscalYear()
sqlConn.ConnectionString = "Server=" & MZKSrv & ";User id=sa;Password=" & MZKPswd & "; Initial Catalog=" & MZKDB & ";"
sqlStr = "INSERT INTO FIN_FiscalYear (Name, StartDate, EndDate, CreatedOn, CreatedBy, CreatedIPAdd) VALUES('strName', 'strStartDate', 'strEndDate', 'strCreatedOn', 'intUser', 'strCreatedIPAdd')"
sqlCmd.Parameters.Add("Name", strName)
sqlCmd.Parameters.Add("StartDate", strStartDate)
sqlCmd.Parameters.Add("EndDate", strEndDate)
sqlCmd.Parameters.Add("CreatedOn", strCreatedOn)
sqlCmd.Parameters.Add("CreatedBy", intUser)
sqlCmd.Parameters.Add("CreatedIPAdd", strCreatedIPAdd)
sqlConn.Open()
sqlTrans = sqlConn.BeginTransaction()
sqlInsert.Connection = sqlConn
sqlInsert.Transaction = sqlTrans
Try
sqlInsert.CommandText = sqlStr
sqlInsert.ExecuteNonQuery()
sqlTrans.Commit()
Debug.WriteLine("Records are written to database.")
Catch e As Exception
Try
sqlTrans.Rollback()
Catch ex As SqlException
If Not sqlTrans.Connection Is Nothing Then
Debug.WriteLine("An exception of type " & ex.GetType().ToString() & " was encountered while attempting to roll back the transaction.")
End If
End Try

Debug.WriteLine("An exception of type " & e.GetType().ToString() & " was encountered while inserting the data.")
Debug.WriteLine("Record was NOT written to database.")
Finally
sqlConn.Close()
End Try
End Function
End Class



Values shown in the Autos window as the program is running just prior to "BeginTransaction".
intUser 1 Integer


Error Message "Syntax error converting the varchar value 'intUser' to a column of data type int."

AnswerRe: Insert to SQL Error Pin
Edbert P13-Oct-05 17:43
Edbert P13-Oct-05 17:43 
GeneralRe: Insert to SQL Error Pin
PAEC14-Oct-05 6:46
PAEC14-Oct-05 6:46 
GeneralRe: Insert to SQL Error Pin
Edbert P16-Oct-05 12:39
Edbert P16-Oct-05 12:39 

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.