Solved

Tinyint via odbc vb.net

Posted on 2011-02-17
7
539 Views
Last Modified: 2012-06-21
Am trying to write value in a db where column type is byte which is odbc type of tinyint.i tried all methods i know but it wont write it.
here is the code that i have so if anyone would be kind to solve me this problem i would appreciate
tryed adding parameters but i don't know how to add them proper
if someone more experienced can change my modify my code to write this tinyint would be great
am using vb.net with vs2010.and am using odbc drivers
Dim oCon As Odbc.OdbcConnection
        Dim cmd As New OdbcCommand
        Dim oPath As String
        oPath = Application.StartupPath
Dim format As Integer = txtvrijednosttest.Text
            Dim kolona As String = "USER"
            oCon = New Odbc.OdbcConnection
            oCon.ConnectionString = "Driver={Topspeed ODBC Driver};Dbq=" & oPath & "\Formati.tps\!;Datefield=MyDateField;|MyOtherDateField;TimeField=MyTimeField|MyOtherTimeField;"
            cmd.CommandText = "INSERT INTO UNNAMED (" & kolona & ") VALUES (format)"
            cmd.Connection = oCon
            oCon.Open()
            cmd.ExecuteNonQuery()
            cmd.Dispose()
            oCon.Close()
            oCon.Dispose()

Open in new window

0
Comment
Question by:LaserAdmin
  • 4
  • 2
7 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
Comment Utility
In your string
cmd.CommandText = "INSERT INTO UNNAMED (" & kolona & ") VALUES (format)"
You must write
cmd.CommandText = "INSERT INTO UNNAMED (" & kolona & ") VALUES (" & format & ")"

Try this. Hope that helps.

0
 

Author Comment

by:LaserAdmin
Comment Utility
tryed but same

need to tell odbc somehow that its tinyint type need that parameter thing
0
 
LVL 25

Expert Comment

by:Luis Pérez
Comment Utility
Do you get some exception, some error message?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
try boolean value

  Dim blval As Boolean
        blval = True
 cmd.CommandText = "INSERT INTO UNNAMED (" & kolona & ") VALUES (" blval ")"

or Int16
  Dim blval As Int16
        blval = 1
 cmd.CommandText = "INSERT INTO UNNAMED (" & kolona & ") VALUES (" blval ")"
0
 

Author Comment

by:LaserAdmin
Comment Utility
lexical element not found <identifier>
odbc driver is topspeed odbc since amsaving to tps db but their odbc is same as standard odbc so strictly stating to it that its tinyint would should work i think
0
 

Accepted Solution

by:
LaserAdmin earned 0 total points
Comment Utility
Solved myself
clarion need $ along with column name to know that its byte type
0
 

Author Closing Comment

by:LaserAdmin
Comment Utility
working on solving this for like 1month and nobody manged to answer my question and after a while i figured myself so i chose my own answer as solution
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now