logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rush  
#1 Posted : Sunday, February 17, 2013 6:14:21 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

If I "update" my online database, that is working.
But if I want to do a "insert into", nothing happens.
All the code works in my visual studio 2012 and SQL server 2008 on my computer.
What do I wrong... are there special things I must know before I upload my code to my hostingfest server before I going to use the next code online?

Here my code:

public void RegisterNewUser(AccountGegevens account, int dropdownlijstSelectie)
{
SqlConnection con = new SqlConnection(this.connectionstring);
string strProduct;
SqlCommand cmd;
try
{
strProduct =
"insert into contactGegevens (voorNaam, achterNaam, straat, nr, postcodeID, email, gsm, telefoon, klantID) values (@voorNaam, @achterNaam, @straat, @nr, @postcodeID, @email, @gsm, @telefoon, @klantID);";
cmd = new SqlCommand(strProduct, con);

cmd.Parameters.AddWithValue("@klantID", this.VulKlantTabel(account));
cmd.Parameters.AddWithValue("@voorNaam", account.VoorNaam);
cmd.Parameters.AddWithValue("@achterNaam", account.AchterNaam);
cmd.Parameters.AddWithValue("@straat", account.Straat);
cmd.Parameters.AddWithValue("@nr", account.Nr);
cmd.Parameters.AddWithValue("@postcodeID", account.PostcodeId);
cmd.Parameters.AddWithValue("@email", account.Email);
cmd.Parameters.AddWithValue("@gsm", account.Gsm);
cmd.Parameters.AddWithValue("@telefoon", account.Telefoon);

con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception)
{
;
}
finally
{
con.Close();
}
}

Edited by user Sunday, February 17, 2013 2:19:58 PM(UTC)  | Reason: Not specified

Smiling4ever  
#2 Posted : Tuesday, February 19, 2013 4:17:29 AM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
Are you getting any exception?
Noman Dormosh

HostingFest
Rush  
#3 Posted : Tuesday, February 19, 2013 9:49:37 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

No, It's working fine in my visual studio on my pc.
I noticed that if I do any "update" to my database online, it's working fine.
But if I do any "insert into" to my database online, result is nothing.

I think it's something about security and that I maybe don't get permission to insert new rows into the database from hostingfest.

Greetings
Kurt
Smiling4ever  
#4 Posted : Wednesday, February 20, 2013 10:25:33 AM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
If your hosting is on SQL 2005 then check queries compatibilities.

Raise a ticket with more details and i'll help you
Noman Dormosh

HostingFest
Rush  
#5 Posted : Thursday, February 21, 2013 10:35:09 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

My hostinfest database is sql server 2008. The same I use on my pc.
I don't see the problem there because I can change my data in my database.
I only can not insert a new row.
What kind of information do you want? I will give it to you.

this works in my online sql server 2008 database:

public void UpdateContactGegevensTabel(AccountGegevens account, int dropdownlijstSelectie)
{
SqlConnection con = new SqlConnection(this.connectionstring);
string strProduct;
SqlCommand cmd;
try
{
strProduct = "update contactGegevens set voorNaam=@voorNaam, achterNaam=@achterNaam, straat=@straat, nr=@nr, postcodeID=@postcodeID, email=@email, gsm=@gsm, telefoon=@telefoon where klantID=@klantID;";
cmd = new SqlCommand(strProduct, con);

cmd.Parameters.AddWithValue("@voorNaam", account.VoorNaam);
cmd.Parameters.AddWithValue("@achterNaam", account.AchterNaam);
cmd.Parameters.AddWithValue("@klantID", account.KlantId);
cmd.Parameters.AddWithValue("@straat", account.Straat);
cmd.Parameters.AddWithValue("@nr", account.Nr);
cmd.Parameters.AddWithValue("@postcodeID", account.PostcodeId);
cmd.Parameters.AddWithValue("@email", account.Email);
cmd.Parameters.AddWithValue("@gsm", account.Gsm);
cmd.Parameters.AddWithValue("@telefoon", account.Telefoon);

con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception)
{
;
}
finally
{
con.Close();
}
}

*********************************************************************************************************
This code works perfect on my computer, but not in my online sql server 2008 from hostingfest:



public void RegistreerNieuweUser(AccountGegevens account, int dropdownlijstSelectie)
{
SqlConnection con = new SqlConnection(this.connectionstring);
string strProduct;
SqlCommand cmd;
try
{
strProduct =
"insert into contactGegevens (voorNaam, achterNaam, straat, nr, postcodeID, email, gsm, telefoon, klantID) values (@voorNaam, @achterNaam, @straat, @nr, @postcodeID, @email, @gsm, @telefoon, @klantID);";
cmd = new SqlCommand(strProduct, con);

cmd.Parameters.AddWithValue("@klantID", this.VulKlantTabel(account));
cmd.Parameters.AddWithValue("@voorNaam", account.VoorNaam);
cmd.Parameters.AddWithValue("@achterNaam", account.AchterNaam);
cmd.Parameters.AddWithValue("@straat", account.Straat);
cmd.Parameters.AddWithValue("@nr", account.Nr);
cmd.Parameters.AddWithValue("@postcodeID", account.PostcodeId);
cmd.Parameters.AddWithValue("@email", account.Email);
cmd.Parameters.AddWithValue("@gsm", account.Gsm);
cmd.Parameters.AddWithValue("@telefoon", account.Telefoon);

con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception)
{
;
}
finally
{
con.Close();
}
}







Smiling4ever  
#6 Posted : Thursday, February 21, 2013 1:23:54 PM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
Ok, the best thing you can do is to debug your code from your localhost but with connection string set to hostingfest DB server.

Check the final query result before calling ExecuteNonQuery
Noman Dormosh

HostingFest
Rush  
#7 Posted : Friday, February 22, 2013 10:16:39 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

Hi,

It doesn't work :(

If I debug from my localhost I use this connection string in my web.config :
<connectionStrings>

<add name="CurtsJam" connectionString="Data Source=localhost;Initial Catalog=CurtsJam;Integrated Security=SSPI;" />

</connectionStrings>




So if I want to debug my code from my localhost with connection string set to hostingfest DB server. I change the connectionstring into this:

<connectionStrings>

<add name="CurtsJam" connectionString="server=mssql.urlcv.com;database=urlcv;user id=kurt;pwd=**password**;" />

</connectionStrings>


It gives me errors If I want to debug...


Maybe its better to zip my solution and a backup from my database, and sent it by mail?

thanks! I appreciate your help !





Smiling4ever  
#8 Posted : Saturday, February 23, 2013 6:58:07 AM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
Your config seems to be fine

What is the exception that you got?
Noman Dormosh

HostingFest
Rush  
#9 Posted : Saturday, February 23, 2013 9:24:54 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

this is the "public void RegistreerNieuweUser" where you asked for with his exception:

public void RegistreerNieuweUser(AccountGegevens account, int dropdownlijstSelectie)
{
SqlConnection con = new SqlConnection(this.connectionstring);
string strProduct;
SqlCommand cmd;
try
{
strProduct =
"insert into contactGegevens (voorNaam, achterNaam, straat, nr, postcodeID, email, gsm, telefoon, klantID) values (@voorNaam, @achterNaam, @straat, @nr, @postcodeID, @email, @gsm, @telefoon, @klantID);";
cmd = new SqlCommand(strProduct, con);

cmd.Parameters.AddWithValue("@klantID", this.VulKlantTabel(account));
cmd.Parameters.AddWithValue("@voorNaam", account.VoorNaam);
cmd.Parameters.AddWithValue("@achterNaam", account.AchterNaam);
cmd.Parameters.AddWithValue("@straat", account.Straat);
cmd.Parameters.AddWithValue("@nr", account.Nr);
cmd.Parameters.AddWithValue("@postcodeID", account.PostcodeId);
cmd.Parameters.AddWithValue("@email", account.Email);
cmd.Parameters.AddWithValue("@gsm", account.Gsm);
cmd.Parameters.AddWithValue("@telefoon", account.Telefoon);

con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception)
{
;
}
finally
{
con.Close();
}
}

And I get this exception:

System.Data.SqlClient.SqlException was caught
Message=Cannot insert the value NULL into column 'contactGegevensID', table 'urlcv.dbo.contactGegevens'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=515
Procedure=""
Server=mssql.urlcv.com
State=2
StackTrace:
bij System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
bij System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
bij System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
bij System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
bij System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
bij System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
bij System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
bij System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
bij System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
bij CurtsJam.Daos.RegistreerNieuweUser(AccountGegevens account, Int32 dropdownlijstSelectie) in C:\Users\gebruiker\Desktop\Bureaublad .NET\backups ecommerce 3\CurtsJam Online - kopieReserve\CurtsJam - E-commerce deel3 implementatie\CurtsJam\daos\Daos.cs:regel 355
InnerException:


This is the function that generate the cliend ID:

public int VulKlantTabel(AccountGegevens account)
{
int werknemerID = 0;
SqlConnection con = new SqlConnection(this.connectionstring);
string strProduct;
SqlCommand cmd;
try
{
strProduct =
"insert into klant (klantLogin, gebruikersNaam, geheimeVraag) values (@klantLogin, @gebruikersNaam, 'mars') " + "SELECT SCOPE_IDENTITY();";
cmd = new SqlCommand(strProduct, con);

cmd.Parameters.AddWithValue("@klantLogin", account.Paswoord);
cmd.Parameters.AddWithValue("@gebruikersNaam", account.GebruikersNaam);
cmd.Parameters.AddWithValue("@geheimeVraag", account.GeheimeVraag);

con.Open();
werknemerID = Convert.ToInt32(cmd.ExecuteScalar().ToString());
}
catch (Exception)
{
;
}
finally
{
con.Close();
}
return werknemerID;

}

And this is the exception I get in "Public int vulKlantTabel" function:


System.Data.SqlClient.SqlException was caught
Message=Cannot insert the value NULL into column 'klantID', table 'urlcv.dbo.klant'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=515
Procedure=""
Server=mssql.urlcv.com
State=2
StackTrace:
bij System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
bij System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
bij System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
bij System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
bij System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
bij System.Data.SqlClient.SqlDataReader.get_MetaData()
bij System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
bij System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
bij System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
bij System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
bij System.Data.SqlClient.SqlCommand.ExecuteScalar()
bij CurtsJam.Daos.VulKlantTabel(AccountGegevens account) in C:\Users\gebruiker\Desktop\Bureaublad .NET\backups ecommerce 3\CurtsJam Online - kopieReserve\CurtsJam - E-commerce deel3 implementatie\CurtsJam\daos\Daos.cs:regel 474
InnerException:


Thanks for the fast reply!
Kurt
Smiling4ever  
#10 Posted : Sunday, February 24, 2013 12:29:55 AM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
Check your (HF DB) tables identity columns, did you set autonumber for them? Did you specify the seeding?

If that did not work, you can zip your code and email it to support. I'll check that for you.
Noman Dormosh

HostingFest
Rush  
#11 Posted : Sunday, February 24, 2013 7:42:50 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

My settings are good (I think):

allow Nulls = no
Data type = int

Condensed Date Type: int
Deterministic : yes
Dts-published: no

Full- text Specification: no
Has Non-Sql server subscriber : no

Identity specification : yes
(is identity) : yes
identity increment : 1
identity seed : 1
indexable : yes
is columnset : no
is sparse : no
Merge-Published : no
Not for replication : yes
replicated : no
RowGuid : no
Size : 4

I zip my code and email it to the support.

Thanks !
Smiling4ever  
#12 Posted : Sunday, February 24, 2013 9:55:31 AM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
I would look into this at low priority if you don't mind, is that fine or you are looking for urgent solution?
Noman Dormosh

HostingFest
Rush  
#13 Posted : Sunday, February 24, 2013 11:36:27 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

Take your time. Glad that you are helping!

In the web.config connection string ... you find the password and username from my (HF DB).

Edited by user Sunday, February 24, 2013 8:10:01 PM(UTC)  | Reason: Not specified

Rush  
#14 Posted : Tuesday, February 26, 2013 4:03:18 AM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

Tis is good to know:

You can find my functions in the map "daos" -> Daos.cs
I use there the next functions:
* public void RegistreerNieuweUser(AccountGegevens account, int dropdownlijstSelectie)
* public int VulKlantTabel(AccountGegevens account)

The page "Registreer.aspx" has the behind code Registreer.aspx.cs uses this functions.

Update the web.config. I did forgot to add next code.

<system.web>
<compilation debug="true" targetFramework="4.0" />

<customErrors mode="Off">
</customErrors>

</system.web>


Thanks !
Smiling4ever  
#15 Posted : Sunday, March 3, 2013 8:22:08 AM(UTC)
Smiling4ever
Rank: Administration

Reputation:

Groups: Administration, Member
Joined: 1/3/2006(UTC)
Posts: 348
Man

Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: Rush Go to Quoted Post
My settings are good (I think):

allow Nulls = no
Data type = int

Condensed Date Type: int
Deterministic : yes
Dts-published: no

Full- text Specification: no
Has Non-Sql server subscriber : no

Identity specification : yes
(is identity) : yes
identity increment : 1
identity seed : 1
indexable : yes
is columnset : no
is sparse : no
Merge-Published : no
Not for replication : yes
replicated : no
RowGuid : no
Size : 4

I zip my code and email it to the support.

Thanks !


Well, i checked your database on the server. Column KlantID does not have the properties quoted above as i told you before.

Just Give this column the Identity=yes and start with seed then it will work.

Good luck
Noman Dormosh

HostingFest
Rush  
#16 Posted : Monday, March 4, 2013 3:32:47 PM(UTC)
Rush
Rank: Newbie

Reputation:

Groups: Member
Joined: 2/17/2013(UTC)
Posts: 9
Man
Belgium
Location: Herentals

Hellow Norman,

It works ! Doing little dance here ;)
Thanks u so very much!

Have a nice day!

Kurt
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.