嗨,大家好,我正在开发一个项目。我的项目将c#中的课程名称,学分和成绩保存到sql中。这是好的。我处理它,但我无法将数据传输到计算机的平均等级上。我想array.could你帮我请我怎样才能将数据从sql导入到c#
-4
A
回答
1
试试这个
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string connStr = "Enter your conneciton string here";
string SQL = "Enter your SQL here";
//uncomment lines below
//SqlDataAdapter adapter = new SqlDataAdapter(SQL, connStr);
//DataTable dt = new DataTable();
//adapter.Fill(dt);
//simulated table
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Age", typeof(int));
dt.Columns.Add("City", typeof(string));
dt.Rows.Add(new object[] { "John", 22, "NY" });
dt.Rows.Add(new object[] { "Mary", 27, "Boston" });
dt.Rows.Add(new object[] { "Paul", 18, "Chicago" });
int count = 0;
foreach (DataRow row in dt.AsEnumerable())
{
Console.WriteLine("Row {0} : {1}", (count++).ToString(), string.Join(",", row.ItemArray.Select(x => x.ToString()).ToArray()));
}
Console.ReadLine();
}
}
}
+0
虽然这个答案可能是正确和有用的,但如果你[包括一些解释一起](http://meta.stackexchange.com/q/114762/159034)来解释它如何帮助解决问题,它是首选。如果存在导致其停止工作并且用户需要了解其曾经工作的变化(可能不相关),这在未来变得特别有用。 –
+0
感谢您的帮助。我不是那个意思。我想我不能明确地抱怨我的问题。 –
相关问题
- 1. 我怎样才能导入System.Windows在C#
- 2. 我怎样才能将gridview数据导出到ms字
- 3. 我怎样才能从数据库
- 4. 我怎样才能加入这个SQL?
- 5. 我怎样才能在SQL
- 6. 我怎样才能在C++
- 7. C++我怎样才能从主
- 8. 我怎样才能从URL
- 9. 我怎样才能从WP7
- 10. 我怎样才能从TEntity
- 11. 我怎样才能从DataGridView
- 12. 我怎样才能从HBITMAP
- 13. 我怎样才能从Excel
- 14. 我怎样才能从Qt
- 15. 我怎样才能得到
- 16. 我怎样才能得到
- 17. 我怎样才能从SQL Server 2008数据库迁移到SQL Server 2000
- 18. 我怎样才能将这些多行数据插入到mysql数据库中
- 19. 我怎样才能将NSMutable数组POST到目标文件c
- 20. 我怎样才能匹配数据插入到我的ComboBox在C#
- 21. 我怎样才能得到我在C中的最后输入(浮点数据)?
- 22. 我我怎样才能AJAX导航
- 23. 我怎样才能将数据传递UIViewContoller从UIView的在swift3
- 24. 我怎样才能json数据jquery
- 25. 我怎样才能访问StackOverflow数据?
- 26. 我怎样才能
- 27. 我怎样才能
- 28. 我怎样才能
- 29. 我怎样才能
- 30. 我怎样才能把从数据的UITextField到IBAction为串
请添加更多的信息,喜欢什么样的SQL语句来把我的成绩在字符串数据,你有什么实际的目标和你有什么成就,直到现在。 – PhilMasterG