geebee
Posts: 21
|
Posted: 05/05/2007, 1:54 PM |
|
Access Database
ASP NET VB
Ver 3.102
Hi,
I am trying to follow the Execute Custom SQL tutorial from the help files but can't get it to work.
I have followed the example and made what I think are the necessary changes to fit my test.
I have placed the following code in the AfterExecuteUdate event as instructed. (the formatting may have been lost when I pasted the code here)
Dim Request As HttpRequest = HttpContext.Current.Request
Dim NewDao As DataAccessObject = Settings.Connection1DataAccessObject
Dim Sql As String = "INSERT INTO People2 (FirstName,Surname) " &"VALUES ("& NewDao.ToSql(Request.QueryString("FirstName"),FieldType._Text) &","& NewDao.ToSql(Request.QueryString("Surname"),FieldType._Text) &")"
NewDao.RunSql(Sql)
When I submit, there are no errors and the People2 Table has a new entry but both fields are empty.
Does anyone see anything wrong with my code?
TIA
Graham
|
|
|
Tuong Do
|
Posted: 05/08/2007, 9:21 PM |
|
I am sure that the Request.QueryString("FirstName) is empty
Try this
<code>
Dim Request As HttpRequest = HttpContext.Current.Request
Dim NewDao As DataAccessObject = Settings.Connection1DataAccessObject
Dim Sql As String = "INSERT INTO People2 (FirstName,Surname) " &"VALUES ("&
NewDao.ToSql(Request.QueryString("FirstName"),FieldType._Text) &","&
NewDao.ToSql(Request.QueryString("Surname"),FieldType._Text) &")"
Response.Write(SQL)
Response.[end]
</code>
"geebee" <geebee@forum.codecharge> wrote in message
news:8463cef0570838@news.codecharge.com...
> Access Database
> ASP NET VB
> Ver 3.102
>
> Hi,
>
> I am trying to follow the Execute Custom SQL tutorial from the help files
> but
> can't get it to work.
>
> I have followed the example and made what I think are the necessary
> changes to
> fit my test.
>
> I have placed the following code in the AfterExecuteUdate event as
> instructed.
> (the formatting may have been lost when I pasted the code here)
>
> Dim Request As HttpRequest = HttpContext.Current.Request
> Dim NewDao As DataAccessObject = Settings.Connection1DataAccessObject
> Dim Sql As String = "INSERT INTO People2 (FirstName,Surname) " &"VALUES
> ("&
> NewDao.ToSql(Request.QueryString("FirstName"),FieldType._Text) &","&
> NewDao.ToSql(Request.QueryString("Surname"),FieldType._Text) &")"
> NewDao.RunSql(Sql)
>
> When I submit, there are no errors and the People2 Table has a new entry
> but
> both fields are empty.
>
> Does anyone see anything wrong with my code?
>
> TIA
>
> Graham
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
geebee
Posts: 21
|
Posted: 05/09/2007, 1:39 PM |
|
Hi Tuong Do, thanks for the reply.
When I run that code, I get an error message
error BC30451: Name 'Response' is not declared.
Any other ideas?
|
|
|
Tuong Do
|
Posted: 05/09/2007, 4:32 PM |
|
You need the full path
Try this again
<code>
Dim Request As HttpRequest = HttpContext.Current.Request
Dim NewDao As DataAccessObject = Settings.Connection1DataAccessObject
Dim Sql As String = "INSERT INTO People2 (FirstName,Surname) " &"VALUES ("&
NewDao.ToSql(Request.QueryString("FirstName"),FieldType._Text) &","&
NewDao.ToSql(Request.QueryString("Surname"),FieldType._Text) &")"
HttpContext.Current.Response.Write(SQL)
HttpContext.Current.Response.[end]
</code>
"Tuong Do" <tuong@somewhere.com> wrote in message
news:f1ri7r$7n7$1@news.codecharge.com...
>I am sure that the Request.QueryString("FirstName) is empty
>
> Try this
>
> <code>
> Dim Request As HttpRequest = HttpContext.Current.Request
> Dim NewDao As DataAccessObject = Settings.Connection1DataAccessObject
> Dim Sql As String = "INSERT INTO People2 (FirstName,Surname) " &"VALUES
> ("&
> NewDao.ToSql(Request.QueryString("FirstName"),FieldType._Text) &","&
> NewDao.ToSql(Request.QueryString("Surname"),FieldType._Text) &")"
>
> Response.Write(SQL)
> Response.[end]
> </code>
>
>
>
> "geebee" <geebee@forum.codecharge> wrote in message
>news:8463cef0570838@news.codecharge.com...
>> Access Database
>> ASP NET VB
>> Ver 3.102
>>
>> Hi,
>>
>> I am trying to follow the Execute Custom SQL tutorial from the help files
>> but
>> can't get it to work.
>>
>> I have followed the example and made what I think are the necessary
>> changes to
>> fit my test.
>>
>> I have placed the following code in the AfterExecuteUdate event as
>> instructed.
>> (the formatting may have been lost when I pasted the code here)
>>
>> Dim Request As HttpRequest = HttpContext.Current.Request
>> Dim NewDao As DataAccessObject = Settings.Connection1DataAccessObject
>> Dim Sql As String = "INSERT INTO People2 (FirstName,Surname) " &"VALUES
>> ("&
>> NewDao.ToSql(Request.QueryString("FirstName"),FieldType._Text) &","&
>> NewDao.ToSql(Request.QueryString("Surname"),FieldType._Text) &")"
>> NewDao.RunSql(Sql)
>>
>> When I submit, there are no errors and the People2 Table has a new entry
>> but
>> both fields are empty.
>>
>> Does anyone see anything wrong with my code?
>>
>> TIA
>>
>> Graham
>>
>>
>> ---------------------------------------
>> Sent from YesSoftware forum
>> http://forums.codecharge.com/
>>
>
>
|
|
|
geebee
Posts: 21
|
Posted: 05/09/2007, 11:40 PM |
|
Hi Tuong Do,
Here are the results, just as you suggested.
INSERT INTO People2 (FirstName,Surname) VALUES (NULL,NULL)
Any ideas why the values are not being picked up?
thanks
|
|
|
Tuong Do
|
Posted: 05/10/2007, 4:08 PM |
|
That mean your request.QueryString is empty OR you mis-spell "FirstName"
And "Surname"
Did you pass the Request.QueryString to this page?
If Firstname and Surname are field on the page then you might consider using
this
NewDao.ToSql(item.Firstname.value,FieldType._Text) &","&
NewDao.ToSql(item.Surname.value,FieldType._Text) &")"
"geebee" <geebee@forum.codecharge> wrote in message
news:84642be6ccaf5a@news.codecharge.com...
> Hi Tuong Do,
>
> Here are the results, just as you suggested.
>
> INSERT INTO People2 (FirstName,Surname) VALUES (NULL,NULL)
>
> Any ideas why the values are not being picked up?
>
> thanks
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
geebee
Posts: 21
|
Posted: 05/12/2007, 12:32 AM |
|
Quote Tuong Do:
If Firstname and Surname are field on the page then you might consider using
this
NewDao.ToSql(item.Firstname.value,FieldType._Text) &","&
NewDao.ToSql(item.Surname.value,FieldType._Text) &")"
Hi Tuong Do,
It works using this code. The database is being populated properly now. I don't understand why the other code wouldn't work but i can look at that again sometime.
Thanks very much for your time and help
|
|
|
|