Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2006, 04:13 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Query Problem.

Hi I am not able to execute following query.
----------------------------------------------
Sub insertrow(Source As Object, e As EventArgs)

        dim str as String
        dim strTsid as String
        dim intTsid as Integer
'' This query is fine.
        str = "select max(tsid) from timesheet"
        DBCommand = New OleDbCommand(str, DBConnection)
        DBReader = DBCommand.ExecuteReader()
        while DBReader.Read()
            intTsid = DBReader(0) + 1
        end while
        DBReader.Close()
        strTsid = intTsid.toString()

''This is where i m facing proble.

        str = "insert into timesheet values(" & strTsid & ",13979," & ProList.SelectedItem.value & "','" & Task.SelectedItem.value & "'," & ActList.SelectedItem.value & "," & WTList.SelectedItem.value & "," & TeamList.SelectedItem.value & "," & Hours.SelectedItem.value &"," & Minutes.SelectedItem.value & ",#" & dt.text & "#,'" & comments.text & "')"

        DBCommand = New OleDbCommand(str, DBConnection)

        DBReader = DBCommand.ExecuteReader()


end sub

----------------------------------------------

It gives error beacuse not able to get values before "ProList.SelectedItem.value" i.e. ignores "strTsid" and '13979'

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
 
Old March 3rd, 2006, 03:53 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Make user this variable, strTsid, has a value.

 
Old March 6th, 2006, 04:34 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

I tested and strTsid has value.

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
 
Old March 6th, 2006, 04:45 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You are constructing a string, so every value you put in the sql string needs to be a character. Convert 13979 to a char. Then before you execute it, response.write sql to see if the syntax is correct.

 
Old March 7th, 2006, 03:02 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

I may convert but in database the field requiers numeric field.

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
 
Old March 7th, 2006, 05:13 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Yes I understand that, but you are contructing a string to execute.. if you do somthing like
str = "insert ..." & sometext & 12345.. you will get an error because of the integer value. You would need:
str = "insert ..." & sometext & '12345'. The db will implicitly convert it to a numeric datatype on the db end.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Problem. rupen Access 3 April 27th, 2007 07:43 AM
Query Problem bundersuk VB Databases Basics 0 December 30th, 2006 07:50 AM
problem with query harpua Classic ASP Databases 1 January 24th, 2005 12:36 PM
Problem in query leo_vinay Classic ASP Databases 5 January 21st, 2005 06:32 AM
query problem mateenmohd SQL Server 2000 7 September 9th, 2003 11:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.