Hello Terry, here is the code:
----
Imports System.Data
Imports System.Data.SqlClient
Imports CrystalDecisions.CrystalReports.Engine
Public Class ved_zpForm
Inherits System.Windows.Forms.Form
Protected Const SQL_CONNECTION_STRING As String = _
"Server=WEBSERVER;" & _
"DataBase=tadaz;" & _
"Integrated Security=SSPI;Connect Timeout=5"
Private ConnectionString As String = SQL_CONNECTION_STRING
Private HasConnected As Boolean = False
Private ServerName As String = "WEBSERVER"
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
'crvVedZP.DisplayToolbar = True
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents crvVedZP As
CrystalDecisions.Windows.Forms.CrystalReportViewer
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents cbData As System.Windows.Forms.ComboBox
Friend WithEvents btnLoad As System.Windows.Forms.Button
Friend WithEvents cbCex As System.Windows.Forms.ComboBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents Ds_existing_tables1 As TadazVB.ds_existing_tables
Friend WithEvents SqlDataAdapter2 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents Ds_cex1 As TadazVB.ds_cex
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents txtBoxNumVed As System.Windows.Forms.TextBox
Friend WithEvents SqlSelectCommand2 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.crvVedZP = New CrystalDecisions.Windows.Forms.CrystalReportViewer()
Me.Label1 = New System.Windows.Forms.Label()
Me.cbData = New System.Windows.Forms.ComboBox()
Me.Ds_existing_tables1 = New TadazVB.ds_existing_tables()
Me.btnLoad = New System.Windows.Forms.Button()
Me.cbCex = New System.Windows.Forms.ComboBox()
Me.Ds_cex1 = New TadazVB.ds_cex()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter()
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection()
Me.SqlDataAdapter2 = New System.Data.SqlClient.SqlDataAdapter()
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand()
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand()
Me.SqlSelectCommand2 = New System.Data.SqlClient.SqlCommand()
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.txtBoxNumVed = New System.Windows.Forms.TextBox()
CType(Me.Ds_existing_tables1,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.Ds_cex1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'crvVedZP
'
Me.crvVedZP.ActiveViewIndex = -1
Me.crvVedZP.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.crvVedZP.DisplayGroupTree = False
Me.crvVedZP.Location = New System.Drawing.Point(16, 64)
Me.crvVedZP.Name = "crvVedZP"
Me.crvVedZP.ReportSource = Nothing
Me.crvVedZP.ShowGroupTreeButton = False
Me.crvVedZP.ShowRefreshButton = False
Me.crvVedZP.Size = New System.Drawing.Size(680, 200)
Me.crvVedZP.TabIndex = 0
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 40)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = "íÅÓÑÃ, ÇÏÄ"
'
'cbData
'
Me.cbData.DataSource = Me.Ds_existing_tables1
Me.cbData.DisplayMember = "sysobjects.data"
Me.cbData.Location = New System.Drawing.Point(96, 40)
Me.cbData.Name = "cbData"
Me.cbData.Size = New System.Drawing.Size(80, 21)
Me.cbData.TabIndex = 5
'
'Ds_existing_tables1
'
Me.Ds_existing_tables1.DataSetName = "ds_existing_tables"
Me.Ds_existing_tables1.Locale = New
System.Globalization.CultureInfo("ru-RU")
Me.Ds_existing_tables1.Namespace =
"
http://www.tempuri.org/ds_existing_tables.xsd"
'
'btnLoad
'
Me.btnLoad.Location = New System.Drawing.Point(616, 16)
Me.btnLoad.Name = "btnLoad"
Me.btnLoad.TabIndex = 6
Me.btnLoad.Text = "úÁÇÒÕÚÉÔØ"
'
'cbCex
'
Me.cbCex.DataSource = Me.Ds_cex1
Me.cbCex.DisplayMember = "spr_sp.sp"
Me.cbCex.Location = New System.Drawing.Point(96, 16)
Me.cbCex.Name = "cbCex"
Me.cbCex.Size = New System.Drawing.Size(56, 21)
Me.cbCex.TabIndex = 7
'
'Ds_cex1
'
Me.Ds_cex1.DataSetName = "ds_cex"
Me.Ds_cex1.Locale = New System.Globalization.CultureInfo("ru-RU")
Me.Ds_cex1.Namespace = "
http://www.tempuri.org/ds_cex.xsd"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(32, 16)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(32, 16)
Me.Label2.TabIndex = 8
Me.Label2.Text = "óð"
'
'Label3
'
Me.Label3.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.Ds_cex1, "spr_sp.naim1"))
Me.Label3.Location = New System.Drawing.Point(176, 16)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(360, 16)
Me.Label3.TabIndex = 9
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "sysobjects", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("data", "data"), New
System.Data.Common.DataColumnMapping("name", "name"), New
System.Data.Common.DataColumnMapping("month", "month"), New
System.Data.Common.DataColumnMapping("YEAR", "YEAR"), New
System.Data.Common.DataColumnMapping("id", "id")})})
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT SUBSTRING(sysobjects.name, 8, 2)
+ RIGHT (sysobjects.name, 4) AS data, sys" & _
"objects.name, spr_months.month, RIGHT (sysobjects.name, 4) AS YEAR,
spr_months.i" & _
"d FROM sysobjects INNER JOIN spr_months ON spr_months.num =
SUBSTRING(sysobjects" & _
".name, 8, 2) WHERE (sysobjects.xtype = 'U') AND (sysobjects.name LIKE
'ozt_vo_%'" & _
") ORDER BY data"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "data source=WEBSERVER;initial
catalog=tadaz;password=a;persist security info=True" & _
";user id=sqluser;workstation id=WEBSERVER;packet size=4096"
'
'SqlDataAdapter2
'
Me.SqlDataAdapter2.DeleteCommand = Me.SqlDeleteCommand1
Me.SqlDataAdapter2.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter2.SelectCommand = Me.SqlSelectCommand2
Me.SqlDataAdapter2.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "spr_sp", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("naim1", "naim1"), New
System.Data.Common.DataColumnMapping("sp", "sp")})})
Me.SqlDataAdapter2.UpdateCommand = Me.SqlUpdateCommand1
'
'SqlDeleteCommand1
'
Me.SqlDeleteCommand1.CommandText = "DELETE FROM spr_sp WHERE (sid =
@Original_sid) AND (naim1 = @Original_naim1 OR @O" & _
"riginal_naim1 IS NULL AND naim1 IS NULL) AND (sp = @Original_sp OR
@Original_sp " & _
"IS NULL AND sp IS NULL)"
Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_sid",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False,
CType(0, Byte), CType(0, Byte), "sid", System.Data.DataRowVersion.Original,
Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_naim1",
System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "naim1",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_sp",
System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "sp",
System.Data.DataRowVersion.Original, Nothing))
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO spr_sp(naim1, sp) VALUES
(@naim1, @sp); SELECT naim1, sp, sid FROM sp" & _
"r_sp WHERE (sid = @@IDENTITY) ORDER BY sp"
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@naim1", System.Data.SqlDbType.VarChar,
255, "naim1"))
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sp", System.Data.SqlDbType.VarChar, 6,
"sp"))
'
'SqlSelectCommand2
'
Me.SqlSelectCommand2.CommandText = "SELECT naim1, sp, sid FROM spr_sp ORDER
BY sp"
Me.SqlSelectCommand2.Connection = Me.SqlConnection1
'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "UPDATE spr_sp SET naim1 = @naim1, sp =
@sp WHERE (sid = @Original_sid) AND (naim1" & _
" = @Original_naim1 OR @Original_naim1 IS NULL AND naim1 IS NULL) AND (sp =
@Orig" & _
"inal_sp OR @Original_sp IS NULL AND sp IS NULL); SELECT naim1, sp, sid FROM
spr_" & _
"sp WHERE (sid = @sid) ORDER BY sp"
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@naim1", System.Data.SqlDbType.VarChar,
255, "naim1"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sp", System.Data.SqlDbType.VarChar, 6,
"sp"))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_sid",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False,
CType(0, Byte), CType(0, Byte), "sid", System.Data.DataRowVersion.Original,
Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_naim1",
System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "naim1",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_sp",
System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "sp",
System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@sid", System.Data.SqlDbType.Int, 4,
"sid"))
'
'Label4
'
Me.Label4.DataBindings.Add(New System.Windows.Forms.Binding("Text",
Me.Ds_existing_tables1, "sysobjects.month"))
Me.Label4.ForeColor = System.Drawing.SystemColors.Control
Me.Label4.Location = New System.Drawing.Point(392, 40)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(72, 24)
Me.Label4.TabIndex = 10
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(232, 40)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(80, 16)
Me.Label5.TabIndex = 11
Me.Label5.Text = "? ×ÅÄÏÍÏÓÔÉ"
'
'txtBoxNumVed
'
Me.txtBoxNumVed.Location = New System.Drawing.Point(328, 40)
Me.txtBoxNumVed.Name = "txtBoxNumVed"
Me.txtBoxNumVed.Size = New System.Drawing.Size(40, 20)
Me.txtBoxNumVed.TabIndex = 12
Me.txtBoxNumVed.Text = ""
'
'ved_zpForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(712, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtBoxNumVed,
Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.cbCex, Me.btnLoad, Me.cbData,
Me.Label1, Me.crvVedZP})
Me.Name = "ved_zpForm"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "÷ÅÄÏÍÏÓÔØ ÎÁ ×ÙÐÌÁÔÕ ÚÁÒÐÌÁÔÙ"
CType(Me.Ds_existing_tables1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.Ds_cex1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLoad.Click
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim drSQL As SqlDataReader
Dim IsConnecting As Boolean = True
While IsConnecting
Try
' Define connection string.
' You may need to change this for your environment.
cnSQL = New SqlConnection(ConnectionString)
cnSQL.Open()
' Instantiate Command Object to execute SQL Statements
cmSQL = New SqlCommand()
' Attach the command to the connection
cmSQL.Connection = cnSQL
' Set the command type to Text
cmSQL.CommandType = CommandType.Text
' START: Commands are for this How-To only.
' Drop GetSelectedCex Store Procedure if it exists.
cmSQL.CommandText = "IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id =
object_id(N'[dbo].[GetDataForVedZP]') and OBJECTPROPERTY(id, N'IsProcedure')
= 1) " & _
"DROP PROCEDURE [dbo].[GetDataForVedZP] "
' Execute the statement
cmSQL.ExecuteNonQuery()
' Create Stored Procedure
'SELECT sp, VO.tn, l_name, f_name, VO.vo, VO.so
'FROM ozt_vo VO INNER JOIN
' ok_main OK ON OK.tn = VO.tn
'WHERE LEFT(VO.sp, 2) = '01'
'ORDER BY VO.sp
Dim text As String = cbData.Text
cmSQL.CommandText = "CREATE PROCEDURE dbo.GetDataForVedZP " & _
"AS " & _
"SELECT VO.sp, VO.tn, OK.l_name, OK.f_name, VO.vo, VO.so " & _
"FROM ozt_vo_" + text + " VO INNER JOIN " & _
"ok_main OK ON VO.tn = OK.tn " & _
"WHERE VO.sp = '" + cbCex.Text + "' " & _
"ORDER BY VO.sp " & _
"Return"
' Execute the statement
cmSQL.ExecuteNonQuery()
' END: Commands for this How-To only.
IsConnecting = False
HasConnected = True
' Close Connection.
'drSQL.Close()
cnSQL.Close()
' Clean up.
cnSQL.Dispose()
cmSQL.Dispose()
Catch Err As Exception
' Report Non SQL Error to the user.
MsgBox(Err.ToString(), MsgBoxStyle.Critical, "General Error")
End Try
End While
' In this event the Customer Orders Report is loaded
' and displayed in the crystal reports viewer.
' This report calls for a parameter which is pulled
' from the customer name combo box (cbCustomers).
' Objects used to set the parameters in the report
Dim pvCollection As New CrystalDecisions.Shared.ParameterValues()
Dim pdvYear As New CrystalDecisions.Shared.ParameterDiscreteValue()
'Define month parameter
Dim pdvMonth As New CrystalDecisions.Shared.ParameterDiscreteValue()
'Define numved
Dim pdvNumVed As New CrystalDecisions.Shared.ParameterDiscreteValue()
Dim pdvCexNum As New CrystalDecisions.Shared.ParameterDiscreteValue()
Dim pdvCexName As New CrystalDecisions.Shared.ParameterDiscreteValue()
' Objects used to set the proper database connection information
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
' Create a report document instance to hold the report
Dim rptVedZP As New ReportDocument()
Try
' Load the report
rptVedZP.Load("..\Reports\ved_zp.rpt")
' Set the connection information for all the tables used in the report
' Leave UserID and Password blank for trusted connection
For Each tbCurrent In rptVedZP.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = ServerName
.UserID = ""
.Password = ""
.DatabaseName = "tadaz"
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent
' Set the discreet value to the customers name.
pdvYear.Value = Mid(cbData.Text, 3, 4)
' Add it to the parameter collection.
pvCollection.Add(pdvYear)
' Apply the current parameter values.
rptVedZP.DataDefinition.ParameterFields("Year").ApplyCurrentValues(pvCollect
ion)
'ïÞÉÓÔËÁ ËÏÌÌÅËÃÉÉ ÐÁÒÁÍÅÔÒÏ×
pvCollection.Clear()
pdvMonth.Value = Label4.Text
pvCollection.Add(pdvMonth)
rptVedZP.DataDefinition.ParameterFields("Month").ApplyCurrentValues(pvCollec
tion)
pvCollection.Clear()
'Number vedom parameter
pdvNumVed.Value = txtBoxNumVed.Text
pvCollection.Add(pdvNumVed)
rptVedZP.DataDefinition.ParameterFields("Num_ved").ApplyCurrentValues(pvColl
ection)
pvCollection.Clear()
pdvCexNum.Value = cbCex.Text
pvCollection.Add(pdvCexNum)
rptVedZP.DataDefinition.ParameterFields("Cex_num").ApplyCurrentValues(pvColl
ection)
pvCollection.Clear()
pdvCexName.Value = Label3.Text
pvCollection.Add(pdvCexName)
rptVedZP.DataDefinition.ParameterFields("Cex_name").ApplyCurrentValues(pvCol
lection)
' Hide group tree for this report
'crvVedZP.DisplayGroupTree = False
' Set the report source for the crystal reports viewer to the
' report instance.
crvVedZP.ReportSource = rptVedZP
' Zoom viewer to fit to the whole page so the user can see the report
crvVedZP.Zoom(1)
Catch Exp As LoadSaveReportException
MsgBox("Incorrect path for loading report.", _
MsgBoxStyle.Critical, "Load Report Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
Private Sub ved_zpForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(Ds_existing_tables1)
SqlDataAdapter2.Fill(Ds_cex1)
End Sub
End Class
----
Regards,
Adriano
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
Without code this is impossible. However, it is telling you that an
identifier of a specific object type is having a method called, but the
identifier is not pointing to an object. In other words it has had its type
declared but either the code failed to instantiate or is missing. Try
stepping thru in debug
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing