ADO.NET问题写错了 [英] ADO.NET Problem write or wrong

查看:55
本文介绍了ADO.NET问题写错了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很简单地试着学习如何使用ADO.NET代码。任何人都可以告诉我

如果我正确使用它?


Imports System.Data.sqlclient

Imports System。数据


公共类Form1


继承System.Windows.Forms.Form


私有子Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim conn As New SqlConnection(" Server = apw-db;"& _

" DataBase = APW-System; Integrated Security = SSPI")

Dim sqlstr As String =" SELECT * FROM sysName" ;

Dim da As SqlDataAdapter

Dim ds作为新数据集

da =新SqlDataAdapter(sqlstr,conn)

da.Fill(ds)

Dim dt As DataTable = ds.Tables(0)

MsgBox(dt.Rows.Item(" sysName" ))''试图显示现场的内容

结束子

结束班

I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me
if I am using it right or not?

Imports System.Data.sqlclient
Imports System.Data

Public Class Form1

Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim conn As New SqlConnection("Server=apw-db;" & _
"DataBase=APW-System; Integrated Security=SSPI")
Dim sqlstr As String = "SELECT * FROM sysName"
Dim da As SqlDataAdapter
Dim ds As New DataSet
da = New SqlDataAdapter(sqlstr, conn)
da.Fill(ds)
Dim dt As DataTable = ds.Tables(0)

MsgBox(dt.Rows.Item("sysName")) ''trying to show what is in field

End Sub
End Class

推荐答案

我正在使用sql 2005 d vb 2005


" Andrew"写道:
I am using sql 2005 and vb 2005

"Andrew" wrote:

我是一个简单的tryint来学习如何使用ADO.NET代码。任何人都可以告诉我

如果我正确使用它?


Imports System.Data.sqlclient

Imports System。数据


公共类Form1


继承System.Windows.Forms.Form


私有子Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim conn As New SqlConnection(" Server = apw-db;"& _

" DataBase = APW-System; Integrated Security = SSPI")

Dim sqlstr As String =" SELECT * FROM sysName" ;

Dim da As SqlDataAdapter

Dim ds作为新数据集

da =新SqlDataAdapter(sqlstr,conn)

da.Fill(ds)

Dim dt As DataTable = ds.Tables(0)

MsgBox(dt.Rows.Item(" sysName" ))''试图展示现场的东西


End Sub

结束类
I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me
if I am using it right or not?

Imports System.Data.sqlclient
Imports System.Data

Public Class Form1

Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim conn As New SqlConnection("Server=apw-db;" & _
"DataBase=APW-System; Integrated Security=SSPI")
Dim sqlstr As String = "SELECT * FROM sysName"
Dim da As SqlDataAdapter
Dim ds As New DataSet
da = New SqlDataAdapter(sqlstr, conn)
da.Fill(ds)
Dim dt As DataTable = ds.Tables(0)

MsgBox(dt.Rows.Item("sysName")) ''trying to show what is in field

End Sub
End Class


安德鲁,


在我的想法中没有任何问题,但是我会在最简单的情况下做到这一点以这种方式格式化


Andrew,

Nothing wrong with in my idea, however I would do it in its simplest format
in this way.

Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim conn As New SqlConnection(" Server = apw-db;" &安培; _

DataBase = APW-System;集成安全性= SSPI)

Dim sqlstr As String =" SELECT * FROM sysName"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim conn As New SqlConnection("Server=apw-db;" & _
"DataBase=APW-System; Integrated Security=SSPI")
Dim sqlstr As String = "SELECT * FROM sysName"



Dim da As new SqlDataAdapter(sqlstr,conn)

Dim da As new SqlDataAdapter(sqlstr, conn)


Dim ds As New DataSet
Dim ds As New DataSet



尝试

Try


da.Fill(ds)
da.Fill(ds)



MessageBox.Show(ds.Tables(0).Rows.Item(" sysName"))''试图显示

什么是字段

Catch ex作为例外

MessageBox.Show(ex.ToString)

结束尝试

MessageBox.Show(ds.Tables(0).Rows.Item("sysName")) ''trying to show
what is in field
Catch ex as Exception
MessageBox.Show(ex.ToString)
End Try


结束子
End Sub



我希望这会有所帮助,


Cor

" Andrew" < An **** @ discussion.microsoft.comschreef in bericht

news:03 ************************ ********** @ microsof t.com ...

I hope this helps,

Cor
"Andrew" <An****@discussions.microsoft.comschreef in bericht
news:03**********************************@microsof t.com...


>我是一个简单的tryint来学习如何使用ADO.NET代码。任何人都可以告诉我

如果我正确使用它?


Imports System.Data.sqlclient

Imports System.Data


公共类Form1


继承System.Windows.Forms.Form


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click


Dim conn As New SqlConnection( Server = apw-db;"& _

DataBase = APW-System; Integrated Security = SSPI")

Dim sqlstr As String =" SELECT * FROM sysName"

Dim da As SqlDataAdapter

Dim ds As New DataSet

da = New SqlDataAdapter(sqlstr,conn)

da.Fill(ds)

Dim dt As DataTable = ds.Tables(0)

MsgBox(dt.Rows.Item( " sysName"))''试图显示字段中的内容

End Sub

结束Cl ass
>I am simple tryint to learn how to use the ADO.NET code. Can anybody tell
me
if I am using it right or not?

Imports System.Data.sqlclient
Imports System.Data

Public Class Form1

Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim conn As New SqlConnection("Server=apw-db;" & _
"DataBase=APW-System; Integrated Security=SSPI")
Dim sqlstr As String = "SELECT * FROM sysName"
Dim da As SqlDataAdapter
Dim ds As New DataSet
da = New SqlDataAdapter(sqlstr, conn)
da.Fill(ds)
Dim dt As DataTable = ds.Tables(0)

MsgBox(dt.Rows.Item("sysName")) ''trying to show what is in field

End Sub
End Class



Andrew写道:
Andrew wrote:

我使用的是sql 2005和vb 2005


" Andrew"写道:
I am using sql 2005 and vb 2005

"Andrew" wrote:

我是一个简单的tryint来学习如何使用ADO.NET代码。任何人都可以告诉我

如果我正确使用它?
I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me
if I am using it right or not?



< snip>


这对我有用:我首先完全忽略了几个向导并尝试创建一个强类型的

版本的数据库。用这种方法挣扎了几天(实际上是b
),我估计我有足够的控制权和ADO.NET知识可以让设计师尝试一下。目前

我正在使用大多数新应用程序的设计师 - 他们真的很酷,如果

你不看他们的衣服...... =))


使用手工制作的强类型数据库系统的经验给我带来了一些

课程,并给了我一个关于ADO.NET的更广泛的视角发动机

工作。如他们所说,您的里程可能会有所不同。并且它允许我足够了解它(我猜),以便在必要时更容易扩展向导生成项目的

功能。


HTH。


问候,


布兰科。

<snip>

This worked for me: I first completely disregarded the several wizards
that come with VB 2005 and tried my hand in creating a strongly-typed
version of a database we have here. After struggling (and actually
succeeding) with this approach for a few days, I reckoned I had enough
control and knowledge of ADO.NET to give the designers a try. Currently
I''m using the designers for most new apps -- they''re actually cool, if
you don''t look under their dresses... =))

The experience with a hand-made strongly-typed db system tought me some
lessons and gave me a broarder perspective of the ADO.NET engine
workings. As they say, your mileage may vary. And it allowed me to
understand enough of it (I guess) to make it easier to extend the
functionality of the wizard generated items when necessary.

HTH.

Regards,

Branco.


这篇关于ADO.NET问题写错了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆