| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1233 人关注过本帖
标题:vb.net于数据库的问题,小妹我看了好久也没能改正这个错误,还请各位高手指 ...
只看楼主 加入收藏
iceblue2005
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-9-13
收藏
 问题点数:0 回复次数:1 
vb.net于数据库的问题,小妹我看了好久也没能改正这个错误,还请各位高手指教!!感

Imports System.Data.SqlClient Imports System.Data

Public Class WebForm1 Inherits System.Web.UI.Page Dim strconn As String = "server=localhost;database=dbcctv;integrated security=true;" Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink Protected WithEvents HyperLink2 As System.Web.UI.WebControls.HyperLink Protected WithEvents Label3 As System.Web.UI.WebControls.Label Dim objconn As New SqlConnection(strconn)

#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList Protected WithEvents DropDownList2 As System.Web.UI.WebControls.DropDownList Protected WithEvents Label1 As System.Web.UI.WebControls.Label Protected WithEvents Label2 As System.Web.UI.WebControls.Label

'注意: 以下占位符声明是 Web 窗体设计器所必需的。 '不要删除或移动它。 Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: 此方法调用是 Web 窗体设计器所必需的 '不要使用代码编辑器修改它。 InitializeComponent() End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then ' 回调的时候初始化 Call dorpyearin() Call dorpweekidin() Call insertintotabviewpoint()'插入的代码 End If End Sub Sub dorpyearin()‘下拉条选年 Dim objconn As New SqlConnection(strconn) Dim mysql As String = "select distinct left(prodate,4) from tabcctv6in" Dim objcomm As New SqlCommand(mysql, objconn) objconn.Open() Dim myreader1 As SqlDataReader myreader1 = objcomm.ExecuteReader DropDownList1.Items.Clear() Do While myreader1.Read() DropDownList1.Items.Add(myreader1.GetValue(0).ToString()) Loop objconn.Close() End Sub

Sub dorpweekidin()‘下拉条选周次,第几周 Dim objconn As New SqlConnection(strconn) Dim mysql As String = "select distinct proweekid from tabcctv6in order by proweekid" Dim objcom As New SqlCommand(mysql, objconn) objconn.Open() Dim myreader2 As SqlDataReader myreader2 = objcom.ExecuteReader DropDownList2.Items.Clear() Do While myreader2.Read() DropDownList2.Items.Add(myreader2.GetValue(0).ToString()) Loop objconn.Close() End Sub

Sub insertintotabviewpoint(),每次从tabcctv6in 依次读出选出值,再对应tabother中相应时间,计算,插入表tabviewponit中 Dim objconn As New SqlConnection(strconn) Dim sqlstrstate As String = "select prodate ,state,dualid ,dualname,startflag ,endflag,timelong,proweek,proweekid from tabcctv6in order by prodate,dualid" '是否插入判定的条件 Dim objcom As New SqlCommand(sqlstrstate, objconn) objconn.Open() Dim myreader As SqlDataReader myreader = objcom.ExecuteReader Do While myreader.Read() '一次读一条语句 Dim stateflag As Int16 = myreader.GetValue(1) '取得状态为state=1 时要插入cctv1的对应收视值

If stateflag = 1 Then '收视份额计算代码 Dim strsmall As String = "startflag < " & myreader.GetValue(4) & "and endflag> " & myreader.GetValue(4) & " and endflag<= " & myreader.GetValue(5) Dim strbt As String = "startflag>=" & myreader.GetValue(4) & " and endflag<= " & myreader.GetValue(5) Dim strbig As String = "startflag>=" & myreader.GetValue(4) & "and startflag< " & myreader.GetValue(5) & " and endflag>" & myreader.GetValue(5) Dim strmop As String = "startflag<" & myreader.GetValue(4) & "and endflag> " & myreader.GetValue(5)

Dim sqlsmall As String = "select viewpoint*(endflag-" & myreader.GetValue(4) & ")/" & myreader.GetValue(6) & "from tabother where " & strsmall & " and prodate='" & myreader.GetValue(0) & "' and chanelid='(CCTV-1).tostring'" Dim sqlbt As String = "select sum(viewpoint*timelong/" & myreader.GetValue(6) & ") from tabother where " & strbt & " and prodate='" & myreader.GetValue(0) & "' and chanelid=(CCTV-1).tostring" Dim sqlbig As String = "select viewpoint*(" & myreader.GetValue(5) & "-startflag)/" & myreader.GetValue(6) & "from tabother where " & strbig & " and prodate='" & myreader.GetValue(0) & " 'and chanelid='(CCTV-1).tostring'" Dim sqlmop As String = "select viewpoint from tabother where " & strmop & "and prodate='" & myreader.GetValue(0) & "'and chanelid=(CCTV-1).tostring"

Dim mycons As New SqlConnection(strconn) Dim mycoms As New SqlCommand(sqlsmall, mycons) mycons.Open() Dim myrds As SqlDataReader myrds = mycoms.ExecuteReader Dim vs As Decimal If myrds.Read() Then vs = (myrds.GetValue(0)).todecimal Else vs = 0 End If mycons.Close() myrds.Close()

Dim myconbt As New SqlConnection(strconn) Dim mycombt As New SqlCommand(sqlbt, myconbt) myconbt.Open() Dim myrdbt As SqlDataReader myrdbt = mycombt.ExecuteReader Dim vbt As Decimal If myrdbt.Read() Then vbt = (myrdbt.GetValue(0)).todecimal '.ToString() If vbt = "" Then vbt = 0 End If Else vbt = 0 End If myrdbt.Close() myconbt.Close()

Dim myconb As New SqlConnection(strconn) Dim mycomb As New SqlCommand(sqlbig, myconb) myconb.Open() Dim myrdb As SqlDataReader myrdb = mycomb.ExecuteReader Dim vb As Decimal If myrdb.Read() Then vb = (myrdb.GetValue(0)).todemical Else vb = 0 End If myconb.Close() myrdb.Close()

Dim myconm As New SqlConnection(strconn) Dim mycomm As New SqlCommand(sqlmop, myconm) myconm.Open() Dim myrdm As SqlDataReader myrdm = mycomm.ExecuteReader Dim vm As Decimal If myrdm.Read() Then vm = (myrdm.GetValue(0)).todemical Else vm = 0 End If myconm.Close() myrdm.Close() '依行插入tabviewpoint表代码 Dim viewpointcctv1 As String = Format(vs + vbt + vb + vm, "#0.00") + "%" ' '"select 0prodate ,1state,2dualid ,3dulaname,4startflag ,5endflag,6timelong,7proweek,8proweekid from tabcctv6in order by prodate,dualid" '是否插入判定条件 Dim strinsertcctv1 As String = "insert into tabviewpoint(chanelid,dualid,proweek,proweekid,prodate,viewpointother)" strinsertcctv1 = strinsertcctv1 + "values('(cctv-1).tostring','" & myreader.GetValue(2) & "','" & myreader.GetValue(7) & "','" & myreader.GetValue(8) & "', '" & myreader.GetValue(0) & "','(viewpointcctv1).tostring')" Dim insertconn As New SqlConnection(strconn) Dim objcommcctv1 As New SqlCommand(strinsertcctv1, insertconn) objcommcctv1.Connection.Open() ' insertconn.Open() objcommcctv1.ExecuteNonQuery() insertconn.Close() End If

Loop objconn.Close() myreader.Close()

End Sub End Class

“/Webcctvadd”应用程序中的服务器错误。 --------------------------------------------------------------------------------

第 1 行: '.' 附近有语法错误。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Data.SqlClient.SqlException: 第 1 行: '.' 附近有语法错误。

源错误:

行 108: myconbt.Open() 行 109: Dim myrdbt As SqlDataReader 行 110: myrdbt = mycombt.ExecuteReader 行 111: Dim vbt As Decimal 行 112: If myrdbt.Read() Then

源文件: C:\Inetpub\wwwroot\Webcctvadd\WebForm1.aspx.vb 行: 110

堆栈跟踪:

[SqlException: 第 1 行: '.' 附近有语法错误。] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) System.Data.SqlClient.SqlCommand.ExecuteReader() Webcctvadd.WebForm1.insertintotabviewpoint() in C:\Inetpub\wwwroot\Webcctvadd\WebForm1.aspx.vb:110 Webcctvadd.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\Webcctvadd\WebForm1.aspx.vb:40 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()

卡到这了,没办法进行下一步,好郁闷的 。要交任务了,心里好急阿 !!! 请高手指教阿 小妹谢谢了, 我的目的是从一个表tabcctv6in中逐行对数据,再从tabother中找到相应的 数据计算后,插入表tabviewpoint中去,一运行就出上面 的错误,真是伤心!!! 我的邮箱,zhangli_gather@sohu.com感谢感谢!!!

搜索更多相关主题的帖子: 数据库 小妹 System Web HyperLink 
2005-09-13 09:38
wwwpig
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-4-7
收藏
得分:0 
好像打开数据库错误

欢迎光临我的阜阳气象台网站 http://rd.
2005-09-18 22:31
快速回复:vb.net于数据库的问题,小妹我看了好久也没能改正这个错误,还请各位高 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047164 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved