473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

insert problem to access db

I run this code to insert some data into an access db

For i = 1 To 14
a = Master.FindControl("centro").FindControl("a" & i.ToString)
'Response.Write(a.Text)
If Len(a.Text) 0 Then
SqlDataSource3.InsertParameters.Add("movimento", id)
SqlDataSource3.InsertParameters.Add("importo", a.text)
SqlDataSource3.InsertParameters.Add("sessione",
Session.SessionID)
SqlDataSource3.Insert()
End If
Next

the problem is that event all the sqls run, values into db are all the same:
the first cicle values.
values are taken correctly as I check them with response.write, but there's
no way to put them into db.

any suggestion?
thanks
Lenny

May 6 '07 #1
6 1002
On May 6, 7:09 pm, "Lenny" <non...@la.dicowrote:
I run this code to insert some data into an access db

For i = 1 To 14
a = Master.FindControl("centro").FindControl("a" & i.ToString)
'Response.Write(a.Text)
If Len(a.Text) 0 Then
SqlDataSource3.InsertParameters.Add("movimento", id)
SqlDataSource3.InsertParameters.Add("importo", a.text)
SqlDataSource3.InsertParameters.Add("sessione",
Session.SessionID)
SqlDataSource3.Insert()
End If
Next

the problem is that event all the sqls run, values into db are all the same:
the first cicle values.
values are taken correctly as I check them with response.write, but there's
no way to put them into db.

any suggestion?
thanks
Lenny
do you mean you have 14 times the same value in "importo"?

May 6 '07 #2
do you mean you have 14 times the same value in "importo"?
yes.
I changed also the other values saved to understand what is saved, and the
values are always the ones of i=1 for 14 times

Lenny

May 6 '07 #3
On May 6, 9:33 pm, "Lenny" <non...@la.dicowrote:
do you mean you have 14 times the same value in "importo"?

yes.
I changed also the other values saved to understand what is saved, and the
values are always the ones of i=1 for 14 times

Lenny
What is the insertcommand for the SqlDataSource3?

May 6 '07 #4
What is the insertcommand for the SqlDataSource3?
>
here it is.

<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:Versamenti %>"
ProviderName="<%$ ConnectionStrings:Versamenti.ProviderName %>"
InsertCommand ="INSERT INTO assegni_euro (Movimento, importo_euro, sessione)
values (:movimento, :importo, :sessione)" DataSourceMode="DataReader" >

</asp:SqlDataSource>

thanks

Lenny

May 6 '07 #5
On May 6, 10:31 pm, "Lenny" <non...@la.dicowrote:
What is the insertcommand for the SqlDataSource3?

here it is.

<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:Versamenti %>"
ProviderName="<%$ ConnectionStrings:Versamenti.ProviderName %>"
InsertCommand ="INSERT INTO assegni_euro (Movimento, importo_euro, sessione)
values (:movimento, :importo, :sessione)" DataSourceMode="DataReader" >

</asp:SqlDataSource>

thanks

Lenny
HA-HA, that's easy...

The InsertParameters.Clear() does the trick

The reason is simple: you have 14 parameters added in the loop and
Insert() method uses only the first one, which is always the same! It
means you should either remove it or clear...

....
If Len(a.Text) 0 Then
SqlDataSource3.InsertParameters.Clear()
SqlDataSource3.InsertParameters.Add("movimento", id)
....

May 6 '07 #6
The reason is simple: you have 14 parameters added in the loop and
Insert() method uses only the first one, which is always the same! It
means you should either remove it or clear...

...
If Len(a.Text) 0 Then
SqlDataSource3.InsertParameters.Clear()
SqlDataSource3.InsertParameters.Add("movimento", id)
...
THAT WORKS !
thank you so much!

Lenny
forever newbie :)
May 7 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: deancoo | last post by:
I have gotten into the habit of often using copy along with an insert iterator. There are scenarios where I process quite a lot of data this way. Can someone give me a general feel as to how much...
0
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
3
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
1
by: Zuggy | last post by:
I'm trying to create a registration/login script using Access 2003. I'm using ADOdb to connect through ODBC. <?php // Connects to your Database include('adodb/adodb.inc.php'); # load code...
5
by: DonnaL | last post by:
I'm using Access 2000, but this question likely pertains to any version of Access. Simply put, is there a programmatic way of inserting a new Query in whatever master system table stores these...
2
by: yeap | last post by:
Hi All, I can't insert java variable into ms access database. I'm using odbc connection to ms access. Below are my coding. try { ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.