.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 5th, 2003, 01:24 AM
aya aya is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 aya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Object must be IConvertible

hi, can anyone please help i've got this set of code that everytime i run i get this error and i dont know what the problem is.<br>the code is:<br><br>Sub doInsert(Source as Object, E as EventArgs)<br> Dim myConnectionString as string ="Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:Inetpubwwwrootdelete asset inwinfix.mdb;"<br> Dim myInsertQuery as string = "Insert into Asset(***_Code, ***_Description, ***_Type, ***_Disposal_Date, " & _<br> "***_Supplier, ***_Serial_Number, ***_Manufacturer, ***_Part_Number, ***_Acquired_Date, ***_Commissioned_Date," & _<br> "***_Original_Cost, ***_Scrap_Value, ***_Notes, ***_Status) " & _<br> "values(?,?,?,?,?,?,?,?,?,?,?,?)"<br>Dim myConnection As New OleDbConnection(myConnectionString)<br> Dim myCommand As New OleDbCommand(myInsertQuery, myConnection)<br> Dim DS As DataSet<br> <br> myCommand.Parameters.Add(New OLEDBParameter("@***_Code", OLEDBType.Char, "20")).Value = ***_Code<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Description", OLEDBType.Char, "50")).Value = ***_Description<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Type", OLEDBType.Char, "2")).Value = ***_Type<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Disposal_Date", OLEDBType.DBDate, "20")).Value = Today.Month & "/" & Today.Day & "/" & Today.Year<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Supplier", OLEDBType.Char, "20")).Value = ***_Supplier<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Serial_number", OLEDBType.Integer)).Value = ***_Serial_Number<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Manufacturer", OLEDBType.Char, "20")).Value = ***_Manufacturer<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Part_number", OLEDBType.Integer)).Value = ***_Part_Number<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Acquired_Date", OLEDBType.DBDate, "20")).Value = Today.Month & "/" & Today.Day & "/" & Today.Year<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Commissioned_Date", OLEDBType.DBDate, "20")).Value = Today.Month & "/" & Today.Day & "/" & Today.Year<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Original_Cost", OLEDBType.Currency)).Value = ***_Original_Cost<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Scrap_Value", OLEDBType.Currency)).Value = ***_Scrap_Value<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Notes", OLEDBType.Char, "100")).Value = ***_Notes<br> myCommand.Parameters.Add(New OLEDBParameter("@***_Status", OLEDBType.Char, "20")).Value = ***_Status<br><br> myCommand.Connection.Open()<br> myCommand.ExecuteNonQuery()<br> MyConnection.Close() <br> <br>End Sub<br><br>i'll be waiting for your suggestions <br>thx

Reply With Quote
  #2  
Old March 5th, 2003, 03:04 AM
Andrew Andrew is offline
dotNetBB Forums Developer
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 265 Andrew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Andrew Send a message via AIM to Andrew Send a message via Yahoo to Andrew
Did you just shorten the code with the ?,?,? part of the SQL?<br><br>If not, then try putting the @***_... parameter name in the correct place.<p><hr size="1" width="50%" align="left" />dotNetBB Forum Developer<br><b><i>Building A Better Community, One Post At A Time</i></b><br><a href="http://www.dotnetbb.com" target="_blank">www.dotnetbb.com</a></p>

Reply With Quote
  #3  
Old March 5th, 2003, 03:06 AM
Andrew Andrew is offline
dotNetBB Forums Developer
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 265 Andrew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Andrew Send a message via AIM to Andrew Send a message via Yahoo to Andrew
Also, instead of using<br><br>myCommand.Parameters.Add(New OLEDBParameter("@***_Code", OLEDBType.Char, "20")).Value = ***_Code<br><br>Try (of course, only dim once)<br><br>Dim myParam as OLEDBParameter = myCommand.Parameters.Add("@***_Code", OLEDBType.Char, "20")<br>myParam.Value = ***_Code<p><hr size="1" width="50%" align="left" />dotNetBB Forum Developer<br><b><i>Building A Better Community, One Post At A Time</i></b><br><a href="http://www.dotnetbb.com" target="_blank">www.dotnetbb.com</a></p>

Reply With Quote
  #4  
Old March 5th, 2003, 03:09 AM
aya aya is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 5 aya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i've tried all ur saying but still getting the same error <img border="0" src="/forum/emoticons/confused.gif" height="22" width="15" alt="confused" />

Reply With Quote
  #5  
Old March 5th, 2003, 03:47 AM
Andrew Andrew is offline
dotNetBB Forums Developer
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 265 Andrew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Andrew Send a message via AIM to Andrew Send a message via Yahoo to Andrew
What line is it erroring on?<p><hr size="1" width="50%" align="left" />dotNetBB Forum Developer<br><b><i>Building A Better Community, One Post At A Time</i></b><br><a href="http://www.dotnetbb.com" target="_blank">www.dotnetbb.com</a></p>

Reply With Quote
  #6  
Old March 5th, 2003, 03:49 AM
Andrew Andrew is offline
dotNetBB Forums Developer
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 265 Andrew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to Andrew Send a message via AIM to Andrew Send a message via Yahoo to Andrew
Oh, one thing I just noticed...<br><br>When passing to non-string values, you must convert the value to the data type being passed. For example<br><br>DBDate : CDate(value)<br>Int : CInt(value)<br>Money : CDbl(value)<p><hr size="1" width="50%" align="left" />dotNetBB Forum Developer<br><b><i>Building A Better Community, One Post At A Time</i></b><br><a href="http://www.dotnetbb.com" target="_blank">www.dotnetbb.com</a></p>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > Object must be IConvertible


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT