Thanks, Cor and Matt.
My problem about crystal report does not stopd there.
I am using this Guid as filter to the where clause unfortunately it is not
working.
How do transfer the string value of certain dropdownlsit control to the
crystal report? Start Date and End Date.
This part is first page, the second page I might need to use SubReport,
which I am new with this.
The first part is a summary of the second page.
There is Company Field which displays company name from db1 of table1,
Company ID id DataValue of dropdownlist 'ddlITP'.
Now, Address Field is located on another database of another server. The
link column is COGUID.
both CompanyID and COGUID is in UniqueIdentifier (Sql Data Type)
Code:
Try
Dim connectString As String = "Provider=SQLOLEDB;data
source=serv1;initial catalog=db1;. . ."
''Create and open a connection using the connection string
Dim adoOleDbConnection As New OleDbConnection(connectString)
''Build a SQL statement to query the datasource
Dim sqlString As String = ""
sqlString = "Select * From table1"
''Retrieve the data using the SQL statement and existing
connection
Dim adoOleDbDataAdapter As New OleDbDataAdapter(sqlString,
adoOleDbConnection)
''Create a instance of a Dataset
Dim DataSet As New DataSet()
''Fill the dataset with the data retrieved. The name of the
table
''in the dataset must be the same as the table name in the
report.
adoOleDbDataAdapter.Fill(DataSet, "table1")
Dim connectString2 As String = "Provider=SQLOLEDB;data
source=serv2;. . ."
''Create and open a connection using the connection string
Dim adoOleDbConnection2 As New OleDbConnection(connectString2)
'Dim adoSqlConnection As New SqlConnection(connectString)
''Build a SQL statement to query the datasource
Dim sqlString2 As String = ""
sqlString2 = "Select * From table2 Where COGUID = ?"
''Retrieve the data using the SQL statement and existing
connection
Dim adoOleDbDataAdapter2 As New OleDbDataAdapter(sqlString2,
adoOleDbConnection2)
'Dim adoSqlDataAdapter As New SqlDataAdapter(sqlString,
adoSqlConnection)
If Me.strCompId = "" Then
Me.strCompId = Me.ddlITP.SelectedItem.Value.ToString()
End If
'Dim coguid As Guid = DirectCast(Me.strCompId, Guid)
'Dim coguid As Guid = CType(Me.ddlITP.SelectedItem, Guid)
Dim coguid As New Guid(Me.strCompId)
adoOleDbDataAdapter2.SelectCommand.Parameters.Add("@COGUID",
OleDbType.VarChar, Me.strCompId.Length, "COGUID").Value = Me.strCompId
''Create a instance of a Dataset
Dim DataSet2 As New DataSet()
''Fill the dataset with the data retrieved. The name of the
table
''in the dataset must be the same as the table name in the
report.
adoOleDbDataAdapter2.Fill(DataSet, "table2")
''Create an instance of the strongly-typed report object
Dim crReportDocument As New Report1C()
''Pass the populated dataset to the report
crReportDocument.SetDataSource(DataSet)
Dim folder As String =
System.IO.Directory.GetCurrentDirectory()
Dim path As String
path = "c:\inetpub\wwwroot\accountweb\Report1C.rpt"
If System.IO.File.Exists(path) = True Then
Dim crConnectionInfo As New ConnectionInfo()
With crConnectionInfo
.ServerName = "serv1"
.DatabaseName = "db1"
.UserID = "user"
.Password = "pass"
End With
'With crConnectionInfo
' .ServerName = "serv2"
' .DatabaseName = "db1"
' .UserID = "user"
' .Password = "password"
'End With
'Get the tables collection from the report object
Dim crDatabase As Database = crReportDocument.Database
Dim crTables As Tables = crDatabase.Tables
Dim crTable As Table
Dim crTableLogOnInfo As TableLogOnInfo
'Apply the logon information to each table in the
collection
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
Me.crvITPReport.ReportSource = crReportDocument
End If
Catch exp As Exception
End Try
[\code]
den2005
--
MCP Year 2005, Philippines
[QUOTE="Cor Ligthert"]
Den,
Yes there is a conversion from string to Guid, it is in the constructor
of
the GUID
http://msdn2.microsoft.com/en-us/library/system.guid.guid(VS.80).aspx
The String Guid has to be correct of course, so you have to use the try
catch.
I hope this helps,
Cor
[QUOTE="den 2005"]
Hi everybody,
I have a column in one of tables in one of the sql server that has a
data
type of
UniqueIdentifier. Now, I am supplying a value to used this column as
filter
to get
specific record.
Note: strCompId is in string datatype.
[code]
adoOleDbDataAdapter2.SelectCommand.Parameters.Add("@compid",
OleDbType.Guid,
Me.strCompId.Length, "COGUID").Value = Me.strCompId
The code shown above causes a conversion error.
There is no conversion from string to GUID. Is there?
Code:
adoOleDbDataAdapter2.SelectCommand.Parameters.Add("@compid",
OleDbType.VarChar, Me.strCompId.Length, "COGUID").Value = Me.strCompId
The code above returns that "@compid" parameter does not exist.
How can I solved this?
Thanks.
den2005