Ok, I'm using code-behind with a MySQL DB to update two tables. It updates the addressbook table fine but the device table won't update. I know its probably some stupid syntax error but I am not seeing it. To be sure I have the right variables set, I am using labels for the IDs. The ID numbers are correct. Can someone help? Thanks. - using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Web;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
using System.Web.UI.HtmlControls;
-
using System.Data.OleDb;
-
using System.Data.Odbc;
-
-
public partial class editassign : System.Web.UI.Page
-
{
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
Session["aspnet"] = Request.QueryString[0];
-
-
int counting = GridView1.Rows.Count;
-
if (counting == 0)
-
{
-
GridView1.Visible = false;
-
Wizard1.Visible = true;
-
}
-
else
-
{
-
GridView1.Visible = true;
-
Wizard1.Visible = false;
-
}
-
}
-
-
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
-
{
-
Session["contact_id"] = this.DropDownList1.SelectedItem.Value;
-
}
-
-
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
-
{
-
Session["device_id"] = this.DropDownList2.SelectedItem.Value;
-
Label1.Text = Convert.ToString(Session["aspnet"]);
-
Label2.Text = Convert.ToString(Session["contact_id"]);
-
Label3.Text = Convert.ToString(Session["device_id"]);
-
}
-
-
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
-
{
-
OdbcConnection con = null;
-
OdbcCommand cmd = null;
-
-
try
-
{
-
con = new OdbcConnection();
-
con.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};server=MyDBServer;database=MyDB;uid=MyUser;pwd=MyPass;";
-
cmd = new OdbcCommand();
-
cmd.Connection = con;
-
cmd.Parameters.Add("?aspnet_id", OdbcType.Int).Value = (Session["aspnet"] != null) ? Convert.ToInt32(Session["aspnet"]) : 1;
-
cmd.Parameters.Add("?contact_id", OdbcType.Int).Value = (Session["contact_id"] != null) ? Convert.ToInt32(Session["contact_id"]) : 0;
-
con.Open();
-
// This one works fine
-
cmd.CommandText = "update egw_addressbook set aspnet_id = ? where contact_id = ?;";
-
cmd.ExecuteNonQuery();
-
-
// These two don't. Even tried combining, no better.
-
cmd.Parameters.Add("?aspnet_id", OdbcType.Int).Value = (Session["aspnet"] != null) ? Convert.ToInt32(Session["aspnet"]) : 1;
-
cmd.Parameters.Add("?device_id", OdbcType.Int).Value = (Session["device_id"] != null) ? Convert.ToInt32(Session["device_id"]) : 0;
-
cmd.CommandText = "update ewise_device set aspnet_id = ? where device_id = ?;";
-
cmd.ExecuteNonQuery();
-
-
cmd.Parameters.Add("?contact_id", OdbcType.Int).Value = (Session["contact_id"] != null) ? Convert.ToInt32(Session["contact_id"]) : 1;
-
cmd.Parameters.Add("?device_id", OdbcType.Int).Value = (Session["device_id"] != null) ? Convert.ToInt32(Session["device_id"]) : 0;
-
cmd.CommandText = "update ewise_device set contact_id = ? where device_id = ?;";
-
cmd.ExecuteNonQuery();
-
}
-
catch (Exception)
-
{
-
throw;
-
}
-
finally
-
{
-
con.Close();
-
}
-
}
-
}
I'm glad you solved your problem.
Next time it would be helpful if you posted the error messages that you are getting. Sometimes it's easier for the experts here to work with error messages rather than having to comb through code to find the problem.
Cheers!
-Frinny
4 1200 TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
I was overloading wizard finish by trying to execute all three queries.
I'm glad you solved your problem.
Next time it would be helpful if you posted the error messages that you are getting. Sometimes it's easier for the experts here to work with error messages rather than having to comb through code to find the problem.
Cheers!
-Frinny
Agreed, sometimes that slips my mind LOL
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jack |
last post by:
Hi,
I'm wondering if someone can help with the following problem. I have
2 tables in an access database from which I would like to create a
third table.
They look like this:
table 1 ...
|
by: info |
last post by:
i researched for a while on the net and found that more people have
this problem, but could not get an answer.
i am very new to MySql.
linux - feudora
i log into mysql using "root"
when...
|
by: Jan Paul van de Berg |
last post by:
Code (ASP/Javascript):
var myMail=Server.CreateObject("CDO.Message");
myMail.Subject="Subject";
myMail.From="info@domain1.blabla";
myMail.To="johndoe@test.blabla";
myMail.TextBody="This is a...
|
by: Luminari |
last post by:
I have two pages. Both of them are supposed to have one table on it
with a fixed header. Both pages were tested in IE6. Structurally they
are identical. Both have a <divthat wraps a <tablethat...
|
by: rhepsi |
last post by:
Hii all,
i have 2 queries, query1 and query 2
Query1 is selecting from results of Query2... is it possible???
Can somebody provide with code snippets in VB.NET to call such queries.
...
|
by: jcocomo |
last post by:
Hi there. I am quite new to MS-Access and databases in general, so please bear with me if this is a very basic question.
I am trying to create a database in Access 2000 that will track patients as...
|
by: Budsy |
last post by:
This is a peculiar problem for me. I am finding that the following query works perfectly and gives the expected result set when used in the Access query design environment, but it simply gives no...
|
by: SydBlack |
last post by:
Hi
I'm creating a simple inventory system with the option to print reports for individual accounts or grand total for all accounts. The individual reports works just fine, but for the grand...
|
by: Phil Gsy |
last post by:
Hi i would like to add a new table (TRADE_SEQ) to my document management database which would contain a squential number in the format currentyear#### so it would start at 20100001. The next sequence...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| | |