Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 3rd, 2006, 04:13 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
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.
  #2 (permalink)  
Old March 3rd, 2006, 03:53 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Make user this variable, strTsid, has a value.

  #3 (permalink)  
Old March 6th, 2006, 04:34 PM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
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.
  #4 (permalink)  
Old March 6th, 2006, 04:45 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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.

  #5 (permalink)  
Old March 7th, 2006, 03:02 PM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
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.
  #6 (permalink)  
Old March 7th, 2006, 05:13 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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.



 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:39 PM.


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