ok ... thanks for the reply
but this is not i wanted...

http://www.codeproject.com/KB/mobile/loginsmartdevicedatabase.aspx

<http://www.codeproject.com/KB/mobile/loginsmartdevicedatabase.aspx>see this
link ... in they have created tableadapter in dataset so they do have to
give path in connection string they have pass the query in table adapter
just by adding new query.and in this sample code , table adapter is created
and is use in the form.this sample code is working well in my pc.

but now before that i tried sql server 2005 database in which i use this
code but i got sqlexception error near con.open() so then i put connection
string in try catch block but now the error is "your connection state is
close it need to opened " this is the code given below

using System.Data.SqlClient;

namespace SmartDeviceProject1
{
    public partial class Form3 : Form
    {
        SqlCommand com;
        SqlConnection con;
        string sql, un, pass, ac, nm, ph;

        public Form3()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //Form3 f3 = new Form3();
            //f3.Close();
            //Form1 f1 = new Form1();
            //f1.open();
        }

        private void button1_Click(object sender, EventArgs e)
        {





                nm = textBox1.Text;
                ph = textBox2.Text;
                un = textBox3.Text;
                pass = textBox4.Text;
                if (radioButton1.Checked == true)
                {
                    ac = radioButton1.Text;
                }
                else
                {
                    ac = radioButton2.Text;
                }

                sql = "insert into
mobileuser(uname,passwd,access,name,phone) values('" + un + "','" + pass +
"','" + ac + "','" + nm + "','" + ph + "')";
                com = new SqlCommand(sql, con);
                com.ExecuteNonQuery();
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                MessageBox.Show("data inserted");



            //catch
            //{
            //}

            //powerDataSet ds = new powerDataSet();
            //powerDataSet.powDataTable dt = new
powerDataSet.powDataTable();



        }

        private void Form3_Load(object sender, EventArgs e)
        {



            con = new SqlConnection(@"Data Source=Data
Source=DON-PC\SQLEXPRESS;Initial Catalog=mobile;Integrated Security=True");
                con.Open();




        }
    }
}

now using this code with sqlceservice and using .sdf local database i always
get an error near connection string that path not found though checked many
time my path was correct but still that errer was there.

so these were i faced using connection string , command statements code...
so when the code given in that linked worked i thought to insert through
tableadapter.. but i dont know how..??

so i want help in that case.. if any wants then i will send u my project to
there personal naik can help me.. i really need help.

thank you..

aditya chavan




On Tue, Mar 30, 2010 at 2:33 PM, Anil Srivastava <[email protected]>wrote:

>
> string str;
> str="insert into <table> values('" +txname.Text +"', "+txtpwd.Text +")";
>
> Aditya
> You are taking too long to learn this.
> Join some Training course nearby.
>
>
>
> On 3/29/10, aditya chavan <[email protected]> wrote:
>>
>> this select data from the table
>> but i want data from textboxes should be inserted through table adapter in
>> database
>>
>> On Mon, Mar 29, 2010 at 5:14 PM, Bernardo Rosmaninho <
>> [email protected]> wrote:
>>
>>> SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM TABLE",
>>> "ConectionString");
>>>
>>>
>>> 2010/3/29 aditya chavan <[email protected]>
>>>
>>>>  hello
>>>>
>>>>
>>>> i have made smart device in which m using *.sdf file as a database.
>>>>
>>>>
>>>> now in this i have created table adapter in the dataset and also made
>>>> insert query command in  table adapter
>>>>
>>>>
>>>> but i dont how to use this insert query in table adapter in c# ..
>>>> so can i geta smaple code how to add or write insert query ..?
>>>>
>>>>
>>>> thank you...
>>>>
>>>>
>>>> Aditya
>>>>
>>>> To unsubscribe from this group, send email to dotnetdevelopment+
>>>> unsubscribegooglegroups.com or reply to this email with the words
>>>> "REMOVE ME" as the subject.
>>>>
>>>
>>>
>>>
>>> --
>>> Bernardo Rosmaninho
>>>
>>>
>>>
>>> To unsubscribe from this group, send email to dotnetdevelopment+
>>> unsubscribegooglegroups.com or reply to this email with the words
>>> "REMOVE ME" as the subject.
>>>
>>>
>>
>>  To unsubscribe from this group, send email to dotnetdevelopment+
>> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
>> ME" as the subject.
>>
>
>

Reply via email to