Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.dotnet.framework.adonet,microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 13
Default insert doen"t work: version 2

Hi,

This is version 2 of my story (in a previous post):

the first time, the record is inserted into the table of excel, but then all
following records are not inserted (and no error message ..) What could that
mean? Where to look for?

This is the first version of the previuos post:

i developped an survey application in asp.net using excel as database (i
know that excel is not ideal for that, but this is the only option). The
person in our compagny who want to make a survey types his questions and
other specifications (type of question, mi/max values ..) in excel and sends
it to me.
I make then a table for gathering the answers.
When someone has answered all the question in the form, he pushes the button
"save" which causes a postback to the page with this javascript code:

.........
inscomm = "insert into data (login," + vragen + waarden
document.getElementById("sql").value=inscomm
document.getElementById("conn").value=conn
document.getElementById("ins").action="survey.aspx "
document.getElementById("ins").submit()
return true;

This is the content of "sql" :
-------------------------
insert into data
(login,vraag1,vraag2,vraag3,vraag4,vraag5,vraag6,v raag7,vraag8,vraag9,vraag10,vraag11,vraag12,vraago 13,vraago14,vraag15,vraag16,vraag17,vraag18,vraag1 9,vraag20,vraag21,vraag22,vraag23,vraag24,vraag25, vraag26,vraago27,vraago28,vraag29,vraag30,vraag31, vraag32,vraag33,vraag34,vraag35,vraag36,vraag37,vr aag38,vraag39,vraag40,vraago41,vraago42,vraag43,vr aag44,vraag45,vraag46,vraag47,vraag48,vraag49,vraa g50,vraag51,vraag52,vraag53,vraag54,vraago55,vraag o56,vraag57,vraag58,vraag59,vraag60,vraag61,vraag6 2,vraag63,vraag64,vraag65,vraag66,vraag67,vraag68, vraago69,vraago70,vraag71,vraag72,vraag73,vraag74, vraag75,vraag76,vraag77,vraag78,vraag79,vraag80,vr aag81,vraag82,vraago83,vraago84,vraag85,vraag86,vr aag87,vraag88,vraag89,vraag90,vraag91,vraag92,vraa g93,vraag94,vraag95,vraag96,vraago97,vraago98,vraa g99,vraag100,vraag101,vraag102,vraag103,vraag104,v raag105,vraag106,vraag107,vraag108,vraag109,vraag1 10,vraago111,vraago112,vraag113,vraag114,vraag115, vraag116,vraag117,vraag118,vraag119,vraag120,vraag 121,vraag122,vraag123,vraag124,vraago125,vraago126 ,vraag127,vraag128,vraag129,vraag130,vraag131,vraa g132,vraag133,vraag134,vraag135,vraag136,vraag137, vraag138,vraago139,vraago140,vraag141,vraag142,vra ag143,vraag144,vraag145,vraag146,vraag147,vraag148 ,vraag149,vraag150,vraag151,vraag152,vraago153,vra ago154,vraag155,vraag156,vraag157,vraag158,vraag15 9,vraag160,vraag161,vraag162,vraag163,vraag164,vra ag165,vraag166,vraago167,vraago168,vraag169,vraag1 70,vraag171,vraag172,vraag173,vraag174,vraag175,vr aag176,vraag177,vraag178,vraag179,vraag180,vraago1 81,vraago182,vraag183,vraag184,vraag185,vraag186,v raag187,vraag188,vraag189,vraag190,vraag191,vraag1 92,vraag193,vraag194,vraago195,vraago196)
values ('1','1','1','1','1','1','1','1','1','1','1','1',' ','
','1','1','1','1','1','1','1','2','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ',' ')

and "conn"::
-----------
Provider = Microsoft.Jet.OLEDB.4.0; Data Source =
c:\inetpub\wwwroot\enquete\excel\ros2rp0607.xls; Extended Properties=Excel
8.0;

Code-behind: If the Request.Form is not empty, the connection is made:
--------------
Imports System.Data.OleDb
Imports System.IO
Partial Class enquete
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim stconn, sqlcomm
sqlcomm = Request.Form("sql")
stconn = Request.Form("conn")
If sqlcomm < "" Then
Dim oConnection As OleDbConnection
Dim sConnection As String
oConnection = New OleDbConnection()
Dim comd As OleDbCommand
sConnection = stconn
oConnection.ConnectionString = sConnection
oConnection.Open()
comd = New OleDbCommand(sqlcomm, oConnection)
comd.ExecuteNonQuery()
oConnection.Close()

Account ASPNET has write rights on excel.
My problem: no error, no message, nothing, only, the table in excel remains
empty.With other words, the insert doesn't occur.
Could someone give me some hints where to look for?
Other surveys with the same code but other excel sheet (other questions)
work. So the code cannot be wrong ...?

Thanks for help
Ben




  #2   Report Post  
Posted to microsoft.public.dotnet.framework.adonet,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert doen"t work: version 2

Have you checked wether you pass in this branch ? My first thought would be
that Request.Form("sql") is just empty (plus it looks like you are not using
the ASP.NET infrastructure ?). You could easily check this by using a
constant for sqlcomm rather than request.Form and see if the insertion
happens.

As a side note my understanding is that you put the SQL statement client
side which is likely not a good idea (attacks can't be made easy as the
attacker knows the SQL string that will be used and could easily change it
without even bothering with an SQL injection attack)...

---
Patrice


"Ben" <b@bn a écrit dans le message de news:
...
Hi,

This is version 2 of my story (in a previous post):

the first time, the record is inserted into the table of excel, but then
all following records are not inserted (and no error message ..) What
could that mean? Where to look for?

This is the first version of the previuos post:

i developped an survey application in asp.net using excel as database (i
know that excel is not ideal for that, but this is the only option). The
person in our compagny who want to make a survey types his questions and
other specifications (type of question, mi/max values ..) in excel and
sends
it to me.
I make then a table for gathering the answers.
When someone has answered all the question in the form, he pushes the
button
"save" which causes a postback to the page with this javascript code:

........
inscomm = "insert into data (login," + vragen + waarden
document.getElementById("sql").value=inscomm
document.getElementById("conn").value=conn
document.getElementById("ins").action="survey.aspx "
document.getElementById("ins").submit()
return true;

This is the content of "sql" :
-------------------------
insert into data
(login,vraag1,vraag2,vraag3,vraag4,vraag5,vraag6,v raag7,vraag8,vraag9,vraag10,vraag11,vraag12,vraago 13,vraago14,vraag15,vraag16,vraag17,vraag18,vraag1 9,vraag20,vraag21,vraag22,vraag23,vraag24,vraag25, vraag26,vraago27,vraago28,vraag29,vraag30,vraag31, vraag32,vraag33,vraag34,vraag35,vraag36,vraag37,vr aag38,vraag39,vraag40,vraago41,vraago42,vraag43,vr aag44,vraag45,vraag46,vraag47,vraag48,vraag49,vraa g50,vraag51,vraag52,vraag53,vraag54,vraago55,vraag o56,vraag57,vraag58,vraag59,vraag60,vraag61,vraag6 2,vraag63,vraag64,vraag65,vraag66,vraag67,vraag68, vraago69,vraago70,vraag71,vraag72,vraag73,vraag74, vraag75,vraag76,vraag77,vraag78,vraag79,vraag80,vr aag81,vraag82,vraago83,vraago84,vraag85,vraag86,vr aag87,vraag88,vraag89,vraag90,vraag91,vraag92,vraa g93,vraag94,vraag95,vraag96,vraago97,vraago98,vraa g99,vraag100,vraag101,vraag102,vraag103,vraag104,v raag105,vraag106,vraag107,vraag108,vraag109,vraag1 10,vraago111,vraago112,vraag113,vraag114,vraag115, vraag116,vraag117,vraag118,vraag119,vraag120,vraag 121,vraag122,vraag123,vraag124,vraago125,vraago126 ,vraag127,vraag128,vraag129,vraag130,vraag131,vraa g132,vraag133,vraag134,vraag135,vraag136,vraag137, vraag138,vraago139,vraago140,vraag141,vraag142,vra ag143,vraag144,vraag145,vraag146,vraag147,vraag148 ,vraag149,vraag150,vraag151,vraag152,vraago153,vra ago154,vraag155,vraag156,vraag157,vraag158,vraag15 9,vraag160,vraag161,vraag162,vraag163,vraag164,vra ag165,vraag166,vraago167,vraago168,vraag169,vraag1 70,vraag171,vraag172,vraag173,vraag174,vraag175,vr aag176,vraag177,vraag178,vraag179,vraag180,vraago1 81,vraago182,vraag183,vraag184,vraag185,vraag186,v raag187,vraag188,vraag189,vraag190,vraag191,vraag1 92,vraag193,vraag194,vraago195,vraago196)
values ('1','1','1','1','1','1','1','1','1','1','1','1',' ','
','1','1','1','1','1','1','1','2','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ','
','1','1','1','1','1','1','1','1','1','1','1','1', ' ',' ')

and "conn"::
-----------
Provider = Microsoft.Jet.OLEDB.4.0; Data Source =
c:\inetpub\wwwroot\enquete\excel\ros2rp0607.xls; Extended Properties=Excel
8.0;

Code-behind: If the Request.Form is not empty, the connection is made:
--------------
Imports System.Data.OleDb
Imports System.IO
Partial Class enquete
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim stconn, sqlcomm
sqlcomm = Request.Form("sql")
stconn = Request.Form("conn")
If sqlcomm < "" Then
Dim oConnection As OleDbConnection
Dim sConnection As String
oConnection = New OleDbConnection()
Dim comd As OleDbCommand
sConnection = stconn
oConnection.ConnectionString = sConnection
oConnection.Open()
comd = New OleDbCommand(sqlcomm, oConnection)
comd.ExecuteNonQuery()
oConnection.Close()

Account ASPNET has write rights on excel.
My problem: no error, no message, nothing, only, the table in excel
remains
empty.With other words, the insert doesn't occur.
Could someone give me some hints where to look for?
Other surveys with the same code but other excel sheet (other questions)
work. So the code cannot be wrong ...?

Thanks for help
Ben






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert objects in .xlsx fails with message "cannot insert object" clacketwood Excel Discussion (Misc queries) 0 February 18th 10 12:16 PM
How do I "insert copied cells"? used to be "alt i e" still work Inserter Excel Worksheet Functions 1 February 14th 09 10:06 PM
Lost "File Menu" - now it's "Edit / View / Insert.." but no "F daves Excel Discussion (Misc queries) 3 April 24th 07 04:52 AM
I cannot get my Excel sheets to "Group". (Student version 2003) OLD Jim New Users to Excel 1 June 29th 06 11:35 AM
Insert "-" in text "1234567890" to have a output like this"123-456-7890" Alwyn Excel Discussion (Misc queries) 3 October 25th 05 11:36 PM


All times are GMT +1. The time now is 06:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"