Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Friday, March 9, 2012

problem when iserting in table

I'm building a form that collects some info from the user (user name, password and type ) and I need to store this info into a table called USER that I created.

I'm using 3 text boxes and a button, when the user clicks the button I need to collect this info and store it into my table

when i click the button i get an error msg in this line (comm.ExecuteNonQuery(); )

what do i need to do?

here is the code

protectedvoid Button1_Click(object sender,EventArgs e)

{

string str ="data source=(local);initial catalog=NH_Project1;integrated security=true;";

SqlConnection conn =newSqlConnection(str);

int rows;

SqlCommand comm =newSqlCommand("INSERT INTO [USER](UserId, UserName, UserPassword, Type)VALUES" +

"@.UsrName,@.UsrPass,@.UsrType", conn);

comm.CommandType =CommandType.Text;

comm.Parameters.AddWithValue("@.UsrName",TextBox1.Text);

comm.Parameters.AddWithValue("@.UsrPass",TextBox2.Text);

comm.Parameters.AddWithValue("@.UsrType", TextBox3.Text);

conn.Open();

rows= comm.ExecuteNonQuery();

conn.Close();

louayazar:

comm.Parameters.AddWithValue("@.UsrName",TextBox1.Text);comm.Parameters.AddWithValue("@.UsrPass",TextBox2.Text);

comm.Parameters.AddWithValue("@.UsrType", TextBox3.Text);

Remove the "@." symbol from your AddWithValue calls. Also, I'd recommend enclosing your ExecuteNonQuery call within a Try/Catch block so you can capture any errors in the future.

|||

Hii

I tried to remove the "@." like what you said but that doesn't work, I still have the same error MSG when clicking the button.

|||

Then make sure to put your ExecuteNonQuery call into a Try/Catch block and see what exception you get. This should help you find out what's going on.

|||

that was helpful, thanks a bunch

Saturday, February 25, 2012

Problem using MSDE

Hi
I have been trying to use the MSDE

info
MSDE installed
sa (has a password)
tried with both mixed and single mode change in registry and later on install
SQL server icon running in the system tray
several reboots and reinstalls over days

I can create a web page that connects to a DB and says connected and disconnected
but I cannot get any data displayed?

I have tried the portal starter Kit and it cannot find the sql server on the install
If I try to do it remotely it wants me to run stuff in a query analyser and some .sql files
but MSDE does not have an interface as such

I am very confused and I just want the system to connect to the db or for the portal to work

Please help

Thank you all in advanceCan you connect to your MSDE through the Server Explorer in Studio?

If so, then you can create a Database Project which will give you a platform from which to interact with your MSDE instance.