LoginSignup
1
1

More than 3 years have passed since last update.

SQLServerのデータ型をC#のデータ型に変換する(データ型のマッピング)

Posted at

SQLServerのデータ型をC#のデータ型に変換する
(SQL Server データ型のマッピング)

対応表

SQL C# キャスト方法
bigint long ToInt64
int long ToInt32
smallint long ToInt16
tinyint long ToByte
real float ToSingle
float double ToDouble

例)
 SQLServerではint型で格納されているデータAを
 VS側で変数に格納したい場合、"ToInt32"を使用する
  int a = Convert.ToInt32(A);

参考資料
『SQL Server データ型のマッピング』
 https://docs.microsoft.com/ja-jp/dotnet/framework/data/adonet/sql-server-data-type-mappings

『C#とSQLServerを繋いでデータを操作する4つの方法【前編】DataTable,SqlDataReader編』
 https://www.udemy.com/course/cs_sqlserver1/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1