2011-09-10 4 views

答えて

1

これはオープンな質問です。あなたがこれを達成するのに役立つチュートリアルがたくさんあります。それはあなたのやりたいことにかかっていますが、MVCは最近進歩する良い方法です。

hereをご覧になり、hereチュートリアルを実行してください。数時間の終わりには、あなたはそれのハングアップを取得します。

MVCを使用したくない場合は、ここに返信して、使用したい技術をより明確にして誰かがあなたを助けてくれるようにしてください。

0
  1. これらのテキストフィールドの値を取得します。
  2. あなたが実装する方法を知りたいなら、あなたは、INSERT INTO TABLE1(COLUMN1、COLUMN2、COLUMN3 ...) VALUES(textBox1.Text .....)

のようなINSERT文を書きますデータベース全体の事はここに行きます:

Using System.Data.SqlClient; 
...... 

    SqlConnection con=new SqlConnection("Data Source=.";Initial 
    Catalog=Northwind;userID=sa;password=123456); 
    SqlCommand cmd=new SqlCommand(); 
    cmd.connection=con; 
    cmd.commandText="INSERT INTO TABLE1 (C1,C2,C3) VALUES (:V1,:V2,V3)"; 
    cmd.Parameters.Add("V1",SqlDBType.Nvarchar).value=textBox1.Text; 
    /*and so on with the next two parameters. If your parameter's type is different 
    you can change NVarchar to other SQL datatypes available from the drop down list 
    and off course you'll have to convert the textBox's value to the appropriate 
    datatype.*/ 
    cmd.ExecuteNonQuery(); 

これは基本的に必要なもののほとんどです。

0

using System.Data.SqlClient;

SqlConnection con = new SqlConnection( "データソース= .....");

SqlCommand cmd = new SqlCommand( "INSERT INTO TableName(StudentId、StudentName、StudentCity)VALUES(@ StudentId、@ StudentName、@ StudentCity)"、con);

cmd.Parameters.AddWithValue( "@ StudentId"、TextBox1.Text);

cmd.Parameters.AddWithValue( "@ StudentName"、TextBox2.Text);

cmd.Parameters.AddWithValue( "@ StudentCity"、TextBox3.Text);

cmd.ExecuteNonQuery();

con.Close();

関連する問題