When you run the code, the following error occurs: 'Number of invalid table'.
Can anyone tell me why?
Does anyone have any example that can help me?
I need to know how to pass the address and password of a database of acces to the report and subreport.
RptDocument.Load("c:\ContDeta.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
Dim CTableLogInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim ConnInfo As CrystalDecisions.Shared.ConnectionInfo = New CrystalDecisions.Shared.ConnectionInfo()
ConnInfo.Type = CrystalDecisions.Shared.ConnectionInfoType.CRQE
ConnInfo.ServerName = String.Empty
ConnInfo.DatabaseName = "c:\5354Tmp_Contadores.mdb"
ConnInfo.Password = Chr(10) & "5354"
ConnInfo.AllowCustomConnection = False
ConnInfo.IntegratedSecurity = False
For Each CTable As CrystalDecisions.CrystalReports.Engine.Table In RptDocument.Database.Tables
CTable.LogOnInfo.ConnectionInfo = ConnInfo
CTableLogInfo = CTable.LogOnInfo
CTableLogInfo.ReportName = "ContDeta.rpt"
CTableLogInfo.TableName = CTable.Name
CTable.ApplyLogOnInfo(CTableLogInfo)
Next
For Each CTable As CrystalDecisions.CrystalReports.Engine.Table In RptDocument.Subreports("Cabecera.rpt").Database.Tables()
CTable.LogOnInfo.ConnectionInfo = ConnInfo
CTableLogInfo = CTable.LogOnInfo
CTableLogInfo.ReportName = "Cabecera.rpt"
CTableLogInfo.TableName = CTable.Name
CTable.ApplyLogOnInfo(CTableLogInfo)
Next
For Each CTable As CrystalDecisions.CrystalReports.Engine.Table In RptDocument.Subreports("Selecciones.rpt").Database.Tables()
CTable.LogOnInfo.ConnectionInfo = ConnInfo
CTableLogInfo = CTable.LogOnInfo
CTableLogInfo.ReportName = "Selecciones.rpt"
CTableLogInfo.TableName = CTable.Name
CTable.ApplyLogOnInfo(CTableLogInfo)
Next
CrystalReportViewer1.ReportSource = RptDocument
Related
Good day,
I am using telerik radgridview hierarchical data in vb.net winforms vs2013.
I am getting this problem, I see correctly the first list in the radgridview and in the first gridviewtemplate, but I do not see a thing in the second gridviewtemplate. I am out of ideas, I post the code here to see if anyone can help me.
Private Function loaddt0() As Data.DataSet
Dim dt As New Data.DataSet
dt.Tables.Add("person")
dt.Tables("person").Columns.Add("personID")
dt.Tables("person").Columns.Add("personName")
For i As Integer = 1 To 3
Dim rw As Data.DataRow
rw = dt.Tables("person").NewRow
rw.Item("personID") = i
rw.Item("personName") = "person" & " - " & i.ToString
dt.Tables("person").Rows.Add(rw)
Next
Return dt
End Function
Private Function loaddt1() As Data.DataSet
Dim dt As New Data.DataSet
dt.Tables.Add("project")
dt.Tables("project").Columns.Add("projectID")
dt.Tables("project").Columns.Add("projectName")
dt.Tables("project").Columns.Add("personID")
dt.Tables("project").Columns.Add("personprojectID")
Dim rw As Data.DataRow
rw = dt.Tables("project").NewRow
rw.Item("projectID") = 1
rw.Item("projectName") = "Proyect 1"
rw.Item("personID") = 1
rw.Item("personprojectID") = "1-1"
dt.Tables("project").Rows.Add(rw)
Dim rw1 As Data.DataRow
rw1 = dt.Tables("project").NewRow
rw1.Item("projectID") = 2
rw1.Item("projectName") = "Proyect 2"
rw1.Item("personID") = 1
rw1.Item("personprojectID") = "1-2"
dt.Tables("project").Rows.Add(rw1)
Dim rw2 As Data.DataRow
rw2 = dt.Tables("project").NewRow
rw2.Item("projectID") = 1
rw2.Item("projectName") = "Proyect 1"
rw2.Item("personID") = 2
rw2.Item("personprojectID") = "2-1"
dt.Tables("project").Rows.Add(rw2)
Dim rw3 As Data.DataRow
rw3 = dt.Tables("project").NewRow
rw3.Item("projectID") = 1
rw3.Item("projectName") = "Proyect 1"
rw3.Item("personID") = 3
rw3.Item("personprojectID") = "3-1"
dt.Tables("project").Rows.Add(rw3)
Return dt
End Function
Private Function loaddt2() As Data.DataSet
Dim dt As New Data.DataSet
dt.Tables.Add("task")
dt.Tables("task").Columns.Add("personprojectID")
dt.Tables("task").Columns.Add("taskID")
dt.Tables("task").Columns.Add("taskName")
dt.Tables("task").Columns.Add("personID")
dt.Tables("task").Columns.Add("personprojecttaskID")
Dim rw As Data.DataRow
rw = dt.Tables("task").NewRow
rw.Item("personprojectID") = "1-1"
rw.Item("taskID") = 3
rw.Item("taskName") = "Task 3"
rw.Item("personID") = 1
rw.Item("personprojecttaskID") = "1-1-3"
dt.Tables("task").Rows.Add(rw)
Dim rw1 As Data.DataRow
rw1 = dt.Tables("task").NewRow
rw1.Item("personprojectID") = "1-1"
rw1.Item("taskID") = 5
rw1.Item("taskName") = "Task 5"
rw1.Item("personID") = 1
rw1.Item("personprojecttaskID") = "1-1-5"
dt.Tables("task").Rows.Add(rw1)
Dim rw2 As Data.DataRow
rw2 = dt.Tables("task").NewRow
rw2.Item("personprojectID") = "1-1"
rw2.Item("taskID") = 8
rw2.Item("taskName") = "Task 8"
rw2.Item("personID") = 1
rw2.Item("personprojecttaskID") = "1-1-8"
dt.Tables("task").Rows.Add(rw2)
Dim rw3 As Data.DataRow
rw3 = dt.Tables("task").NewRow
rw3.Item("personprojectID") = "1-2"
rw3.Item("taskID") = 6
rw3.Item("taskName") = "Task 6"
rw3.Item("personID") = 1
rw3.Item("personprojecttaskID") = "1-2-6"
dt.Tables("task").Rows.Add(rw3)
Dim rw4 As Data.DataRow
rw4 = dt.Tables("task").NewRow
rw4.Item("personprojectID") = "2-1"
rw4.Item("taskID") = 1
rw4.Item("taskName") = "Task 1"
rw4.Item("personID") = 1
rw4.Item("personprojecttaskID") = "2-1-1"
dt.Tables("task").Rows.Add(rw4)
Dim rw5 As Data.DataRow
rw5 = dt.Tables("task").NewRow
rw5.Item("personprojectID") = "3-1"
rw5.Item("taskID") = 8
rw5.Item("taskName") = "Task 8"
rw5.Item("personID") = 3
rw5.Item("personprojecttaskID") = "3-1-8"
dt.Tables("task").Rows.Add(rw5)
Return dt
End Function
Private Sub load2()
Dim ldt As Data.DataSet
ldt = loaddt0()
rgvtareas.DataSource = ldt.Tables("person").DefaultView
ldt.Dispose()
Dim gridviewtemple As New Telerik.WinControls.UI.GridViewTemplate
Dim ldt2 As Data.DataSet
ldt2 = loaddt1()
gridviewtemple.DataSource = ldt2.Tables("project").DefaultView
ldt2.Dispose()
Dim ldt3 As Data.DataSet
ldt3 = loaddt2()
Dim gridviewtemple2 As New Telerik.WinControls.UI.GridViewTemplate
gridviewtemple2.DataSource = ldt3.Tables("task").DefaultView
ldt3.Dispose()
rgvtareas.MasterTemplate.Templates.Add(gridviewtemple)
Dim relation As New Telerik.WinControls.UI.GridViewRelation(rgvtareas.MasterTemplate)
relation.ChildTemplate = gridviewtemple
relation.RelationName = "PERSONS - PROJECTS"
relation.ParentColumnNames.Add("personID")
relation.ChildColumnNames.Add("personID")
rgvtareas.Relations.Add(relation)
gridviewtemple.AllowAddNewRow = False
gridviewtemple.AllowDragToGroup = False
gridviewtemple.AllowDeleteRow = False
gridviewtemple.AllowEditRow = False
gridviewtemple.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
'Me.cargaridiomagrv3(gridviewtemple2)
'Me.dgdarformatogvt(gridviewtemple)
gridviewtemple.Templates.Add(gridviewtemple2)
Dim relation2 As New Telerik.WinControls.UI.GridViewRelation(gridviewtemple)
relation2.ChildTemplate = gridviewtemple2
relation2.RelationName = "PERSONPROJECTS - TASKS"
relation2.ParentColumnNames.Add("personprojectID")
relation2.ChildColumnNames.Add("personprojectID")
gridviewtemple2.AllowAddNewRow = False
gridviewtemple2.AllowDragToGroup = False
gridviewtemple2.AllowDeleteRow = False
gridviewtemple2.AllowEditRow = False
gridviewtemple2.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
rgvtareas.Refresh()
End Sub
The image of what I get is:
You've missed adding the second GridViewRelation to the Relations collection of the control. Just add this line at the bottom:
rgvtareas.Relations.Add(relation2)
I'm executing a Oracle stored procedure which has three output parameters and those are returning results in table format. I'm using array to capture those results. Here I'm getting this issue. Also kindly verify my stuff, does it make sense?
Dim cmd As New OracleCommand("PKG_HOBS.PRC_HOBS_GET_CLIENTID", FPP1_Connection)
cmd.CommandType = CommandType.StoredProcedure
Dim p1 As New OracleParameter(":obus_grp_id", OracleDbType.Int64, ParameterDirection.Output)
p1.OracleDbType = OracleDbType.Int64
p1.Direction = ParameterDirection.Output
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p1.Size = 100 ' This is the size of items in array in THIS case
p1.ArrayBindSize = New Integer() {100}
cmd.Parameters.Add(p1)
Dim p2 As New OracleParameter(":ostat_c", OracleDbType.Int64, ParameterDirection.Output)
p2.OracleDbType = OracleDbType.Int64
p2.Direction = ParameterDirection.Output
p2.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p2.Size = 100 ' This is the size of items in array in THIS case
p2.ArrayBindSize = New Integer() {100}
cmd.Parameters.Add(p2)
Dim p3 As New OracleParameter(":ostat_msg_x", OracleDbType.Varchar2, 500, ParameterDirection.Output)
p3.OracleDbType = OracleDbType.Varchar2
p3.Direction = ParameterDirection.Output
p3.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p3.Size = 500 ' This is the size of items in array in THIS case
p3.ArrayBindSize = New Integer() {500}
cmd.Parameters.Add(p3)
FPP1_Connection.Open()
cmd.ExecuteNonQuery()
I found the solution for this question. Hope it will help for some one. We have to use Enumerable.repeat for string data type.
Dim cmd As New OracleCommand("PKG_HOBS.PRC_HOBS_GET_CLIENTID", FPP1_Connection)
cmd.CommandType = CommandType.StoredProcedure
'Passing three parameters and retriving the results in array
Dim p1 As New OracleParameter("obus_grp_id", OracleDbType.Int64, ParameterDirection.Output)
p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p1.Size = 100
cmd.Parameters.Add(p1)
Dim p2 As New OracleParameter("ostat_c", OracleDbType.Int64, ParameterDirection.Output)
p2.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p2.Size = 100
cmd.Parameters.Add(p2)
Dim p3 As New OracleParameter("ostat_msg_x", OracleDbType.Varchar2, ParameterDirection.Output)
p3.CollectionType = OracleCollectionType.PLSQLAssociativeArray
p3.Size = 100
p3.ArrayBindSize = Enumerable.Repeat(500, 100).ToArray
cmd.Parameters.Add(p3)
cmd.ExecuteNonQuery()
Try
'Assigning each parameter values into local variables
Dim oraobus_grp_id() As OracleDecimal = CType(p1.Value, OracleDecimal())
Dim oraostat_c() As OracleDecimal = CType(p2.Value, OracleDecimal())
Dim oraostat_msg_x() As OracleString = CType(p3.Value, OracleString())
Dim obus_grp_idVal(oraobus_grp_id.Length - 1) As Long
Dim ostat_cVal(oraostat_c.Length - 1) As Long
Dim ostat_msg_xVal(oraostat_msg_x.Length - 1) As String
For i As Integer = 0 To oraobus_grp_id.Length - 1
obus_grp_idVal(i) = Convert.ToInt64(oraobus_grp_id(i).ToString)
ostat_cVal(i) = Convert.ToInt64(oraostat_c(i).ToString)
If ostat_cVal(i) <> "0" And ostat_cVal(i) <> "800" Then
If Not oraostat_msg_x(i).IsNull Then
ostat_msg_xVal(i) = Convert.ToString(oraostat_msg_x(i).Value)
Dts.Events.FireError(-1, "", "Error response in new client retrieval: " + ostat_msg_xVal(i), "", 0)
Else
ostat_msg_xVal(i) = Nothing
Dts.Events.FireError(-1, "", "Error response in new client retrieval: " + ostat_msg_xVal(i), "", 0)
End If
Else
Call InsertClient(obus_grp_idVal(i))
End If
Next
I need to perform this SQL Query:
UPDATE Resurses SET GrpPwd = #GrpPwd1 WHERE Resurs = #Resurs1
For all rows in my Access Database using VB.NET
How can i do it?
I use this code but id doesn't work:
Password Generator:
Dim charset As String = nalf
Dim r As New Random()
Dim lenPass As Integer = r.Next(minLength, maxLength)
Dim str As String = String.Empty
For i As Integer = 0 To lenPass - 1
str += charset(r.Next(0, charset.Length))
Next
Return str
End Function
Update rows
If DataGridView1.CurrentRow.Cells(3).Value = "Yes" Then
nres = DataGridView1.CurrentRow.Cells(0).Value
nalf = DataGridView1.CurrentRow.Cells(6).Value
nsym = DataGridView1.CurrentRow.Cells(1).Value
Dim parol1 As String
Dim pwd As String = pass99(nsym, nsym) '
parol1 = pwd
Dim cmd As New OleDbCommand()
Dim Conn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.oledb.12.0; Data source=" + bpath)
cmd.Connection = Conn
Conn.Open()
For i As Integer = 0 To k - 1
cmd.CommandText = String.Format("UPDATE Resurses SET GrpPwd = #GrpPwd1{0} WHERE Resurs = #Resurs1{0};", i)
cmd.Parameters.Add(String.Format("#GrpPwd1{0}", i), OleDbType.WChar).Value = parol1
cmd.Parameters.Add(String.Format("#Resurs1{0}", i), OleDbType.Integer).Value = nres
Next
cmd.ExecuteNonQuery()
Conn.Close()
MsgBox("All rows are updated!")
End If
f
I have data Column type: system.int32 and I want to save a normal Integer value in it.
For Example
I want to save the Integer "1" into a system.int32 column.
Then a exception is thrown which says
"The Value is more then The Max.length of this column".
Got any one an Idea?
Edit:
Here is the code:
Dim reader As OleDbDataReader = Nothing
Dim schemaTable As DataTable = New DataTable
Dim dt As DataTable = New DataTable
sql = "SELECT * from " & TabName
mCmd.CommandText = sql
reader = mCmd.ExecuteReader(CommandBehavior.KeyInfo)
schemaTable = reader.GetSchemaTable()
Dim dc As DataColumn
Dim key As Integer = 0
Dim ColumnOrdinal As Integer
For Each myField As DataRow In schemaTable.Rows
dc = New DataColumn
For Each myProperty As DataColumn In schemaTable.Columns
' Console.WriteLine(myProperty.ColumnName + " = " + myField(myProperty).ToString())
System.Diagnostics.Debug.WriteLine(myProperty.ColumnName + " = " + myField(myProperty).ToString())
If myProperty.ColumnName = "ColumnName" Then dc.ColumnName = myField(myProperty)
If myProperty.ColumnName = "ColumnOrdinal" Then ColumnOrdinal = myField(myProperty)
If myProperty.ColumnName = "DataType" Then dc.DataType = myField(myProperty)
If myProperty.ColumnName = "IsAutoIncrement" Then dc.AutoIncrement = myField(myProperty)
If myProperty.ColumnName = "ReadOnly" Then dc.ReadOnly = myField(myProperty)
If myProperty.ColumnName = "IsUnique" Then dc.Unique = myField(myProperty)
If myProperty.ColumnName = "ColumnSize" Then dc.MaxLength = myField(myProperty)
If myProperty.ColumnName = "IsKey" AndAlso myField(myProperty) = True Then key = ColumnOrdinal
' System.Diagnostics.Debug.WriteLine(myProperty.DataType)
Next
If dc.AutoIncrement = False Then
dt.Columns.Add(dc)
End If
Next
When at this line myProperty pases datatyp Int32
If myProperty.ColumnName = "DataType" Then dc.DataType = myField(myProperty)
I get the exception during filling the datatable which I created above.
Here is the code:
Dim reader As StreamReader = Nothing
reader = New StreamReader(File, Encoding.Default)
Do Until reader.EndOfStream
Textzeile = reader.ReadLine()
spalten = reader.ReadLine().Split(";"c)
Dim dr As DataRow = Nothing
dr =dt.NewRow()
For i As Integer = 0 To dt.Columns.Count - 1
dr(i) = spalten(i)
Next
dt.Rows.Add(dr)
.
.
.
At this line the exception is thrown
dt.Rows.Add(dr)
Edit2: Problem solved. As we commented out Columnsize it worked.I would love to know why it works now. Columnsize was inizialized with 4 as it did not work.
in my form, when i modify data i'm getting error as
'Command text was not set for the command object'
I'm using oledb connection
Following us my code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
sql = "select * from Employee"
conn = New OleDbConnection(s)
adapt = New OleDbDataAdapter(sql, conn)
ds = New DataSet
usql = "Update Employee set enp_name=?, emp_addr=?, DOB=?, DOJ=?, emp_mob=?, emp_mail=? where ID=?"
ucmd = New OleDbCommand(isql, conn)
Dim date1 As Date
date1 = DateTimePicker1.Value
p = ucmd.Parameters.Add("#emp_name", OleDbType.Char)
p.SourceColumn = "emp_name"
p.SourceVersion = DataRowVersion.Current
p = ucmd.Parameters.Add("#emp_addr", OleDbType.Char)
p.SourceColumn = "emp_addr"
p.SourceVersion = DataRowVersion.Current
p = ucmd.Parameters.Add("#DOB", OleDbType.DBDate)
p.SourceColumn = "DOB"
p.SourceVersion = DataRowVersion.Current
p = ucmd.Parameters.Add("#DOJ", OleDbType.DBDate)
p.SourceColumn = "DOJ"
p.SourceVersion = DataRowVersion.Current
p = ucmd.Parameters.Add("#emp_mob", OleDbType.Integer)
p.SourceColumn = "emp_mob"
p.SourceVersion = DataRowVersion.Current
p = ucmd.Parameters.Add("#emp_mail", OleDbType.Char)
p.SourceColumn = "emp_mail"
p.SourceVersion = DataRowVersion.Current
p = ucmd.Parameters.Add("#ID", OleDbType.Integer)
p.SourceColumn = "ID"
p.SourceVersion = DataRowVersion.Current
adapt.UpdateCommand = ucmd
conn.Open()
If conn.State = ConnectionState.Open Then
adapt.MissingSchemaAction = MissingSchemaAction.AddWithKey
adapt.Fill(ds, "ABC")
'conn.Close()
End If
tables = ds.Tables
table = tables("ABC")
rows = table.Rows
cols = table.Columns
row = rows.Find(TextBox1.Text)
row.BeginEdit()
row("ID") = TextBox1.Text
row("emp_name") = TextBox2.Text
row("emp_addr") = TextBox3.Text
row("DOB") = DateTimePicker1.Text
row("DOJ") = DateTimePicker2.Text
row("emp_mob") = TextBox4.Text
row("emp_mail") = TextBox5.Text
row.EndEdit()
'conn.Open()
adapt.Update(ds, "ABC")** Getting error on this line
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
But i'm not getting where i'm going wrong.... please help me
You are not setting usql to the ucmd anywhere.
ucmd.CommandText = usql;
Or rather, in your constuctor:
ucmd = New OleDbCommand(isql, conn)
isql should probably be usql. I am guessing there is an isql string field in the class if you are not getting compilation errors.