検索
ホームページデータベースmysql チュートリアルGridView读取数据XLS ACCESS MDB 并写入到数据库

%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReadExcel_CS.aspx.cs" Inherits="ReadExcel_CS" % !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html xmlns="http



    无标题页


   

   

       
       
            

         
           
            

   

   



-------------------------------------

   using System;
 using System.Data;
 using System.Configuration;
 using System.Collections;
 using System.Web;
 using System.Web.Security;
 using System.Web.UI;
 using System.Web.UI.WebControls;
 using System.Web.UI.WebControls.WebParts;
 using System.Web.UI.HtmlControls;
 using System.Data.OleDb;
 
 public partial class ReadExcel_CS : System.Web.UI.Page
{
     public DataTable DT;
     protected void Page_Load(object sender, EventArgs e)
     {
         //read excel file
         string strConn;
         strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
         "Data Source=C://test.xls;" +
         "Extended Properties=Excel 8.0;";
 
         OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
 
         DataSet myDataSet = new DataSet();
         myCommand.Fill(myDataSet, "ExcelInfo");
         this.GridView1.DataSource = myDataSet.Tables["ExcelInfo"].DefaultView;
         this.GridView1.DataBind();

          DT = (DataTable)myDataSet.Tables["ExcelInfo"];
         /*
         //read access file
         string strConn2;
         strConn2 = "Provider=Microsoft.Jet.OLEDB.4.0;" +
         "Data Source=c://test.mdb;" +
         "Persist Security Info=True;";
 
         OleDbDataAdapter myCommand2 = new OleDbDataAdapter("select * from test", strConn2);
 
         DataSet myDataSet2 = new DataSet();
         myCommand2.Fill(myDataSet2, "AccessInfo");
         this.GridView2.DataSource = myDataSet2.Tables["AccessInfo"].DefaultView;
         this.GridView2.DataBind();
          */
 
     }
     protected void Button1_Click(object sender, EventArgs e)
     {
         /*
         //写入数据库david
         for (int i = 1; i          {
             for (int j = 1; j              {
                 string a = GridView1.Rows[i].Cells[j].ToString() ;
                 Response.Write(a.ToString() ); 
             }
            
         }
          */
         for (int i = 0; i          {
             //for (int j = 0; j              //{
                 string A=DT.Rows[i][0].ToString();
                 string B= DT.Rows[i][1].ToString();
                 string C = DT.Rows[i][2].ToString();
                 string D = DT.Rows[i][3].ToString();

                 string sqlinsert = "insert TEST(A,B,C,D)values('"+A+"','"+B+"','"+C+"','"+D+"')";
                 DataAccess.DataAccessSHDB.GetNonQuery(sqlinsert.ToString());  
                 //Response.Write(a.ToString()+","); 
             //}
         }
     }
 }

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
MySQL文字列タイプ:ストレージ、パフォーマンス、ベストプラクティスMySQL文字列タイプ:ストレージ、パフォーマンス、ベストプラクティスMay 10, 2025 am 12:02 AM

mysqlstringTypesimpactStorageandperformanceAseasfollows:1)churisfixed-regents、whuscanbasterbutlessspace-efficient.2)varcharisvariaible、morespace-efficient-butpotentiallyslower.3)Textisforgergetext、storedoutext、

MySQL文字列タイプの理解:Varchar、Text、CharなどMySQL文字列タイプの理解:Varchar、Text、CharなどMay 10, 2025 am 12:02 AM

mysqlstringTypesincludevarchar、テキスト、char、列挙、およびセット。1)varcharisSatileforvariaible-lengthstringsuptoaspoecifedlimit.2)TextisidealforLargetExtStorageWithDeinLength.3)charispixed-consinterconsistentalikodes.4)

MySQLの文字列データ型は何ですか?MySQLの文字列データ型は何ですか?May 10, 2025 am 12:01 AM

mysqloffersvariousstringdatatypes:1)charfixed-lengthstrings、2)varcharforvariable-lengthtext、3)binaryandvartyforbinarydata、4)blobandtextforlargedata、and5)enumandsetforControlledinput.

新しいMySQLユーザーに権限を付与する方法新しいMySQLユーザーに権限を付与する方法May 09, 2025 am 12:16 AM

tograntpermissionstonewmysqlusers、フォローステープ:1)Accessmysqlasauserwithsufthiveerprivileges、2)createanewuser withthecreateusercommand、3)usethegrantcommandtospecifypermissionsionsionsionsionsionsionsionsionsionsionselect、挿入、挿入、挿入、更新、4)

MySQLにユーザーを追加する方法:ステップバイステップガイドMySQLにユーザーを追加する方法:ステップバイステップガイドMay 09, 2025 am 12:14 AM

toadduusersinmysqucrectivally andcurally、soflowthesteps:1)usethecreateuserstatementtoaddanewuser、指定するhostandastrongpassword.2)補助金を使用して、補助金を使用して、補助すること、

MySQL:複雑な権限を持つ新しいユーザーの追加MySQL:複雑な権限を持つ新しいユーザーの追加May 09, 2025 am 12:09 AM

toaddanewuserwithpermissionsinmysql、followthesesteps:1)createtheuserwithcreateuser'newuser '@' localhost'identifiedifiedifiedifiedby'pa ssword ';。2)grantreadacestoalltablesin'mydatabase'withgrantselectonmydatabase.to'newuser'@'localhost';。3)grantwriteaccessto '

MySQL:文字列データ型とコレクションMySQL:文字列データ型とコレクションMay 09, 2025 am 12:08 AM

MySQLの文字列データ型には、CHAR、VARCHAR、バイナリ、Varbinary、BLOB、およびテキストが含まれます。照合は、文字列の比較とソートを決定します。 1.Charは固定長の文字列に適しており、Varcharは可変長文字列に適しています。 2.バイナリとVarbinaryはバイナリデータに使用され、BLOBとテキストは大規模なオブジェクトデータに使用されます。 3. UTF8MB4_UNICODE_CIなどのルールのソートは、高度と小文字を無視し、ユーザー名に適しています。 UTF8MB4_BINは症例に敏感であり、正確な比較が必要なフィールドに適しています。

MySQL:Varcharsにはどの長さを使用すればよいですか?MySQL:Varcharsにはどの長さを使用すればよいですか?May 09, 2025 am 12:06 AM

最適なMySQLVarcharの列の長さの選択は、データ分析に基づいており、将来の成長を検討し、パフォーマンスの影響を評価し、文字セットの要件を評価する必要があります。 1)データを分析して、典型的な長さを決定します。 2)将来の拡張スペースを予約します。 3)パフォーマンスに対する大きな長さの影響に注意してください。 4)ストレージに対する文字セットの影響を考慮します。これらの手順を通じて、データベースの効率とスケーラビリティを最適化できます。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

SecLists

SecLists

SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター