Hello coders, I have developed a project in VB.Net and SQL Server and after creating a setup of the project and installed on the client's PC, the CRUD operations are working just fine but crystal report shows an error that the database cannot be found due to wrong path which is like "D:\myproject\bin\Debug cannot be found.
Since the CRUD operations and reporting are working fine on my PC but reporting is not working on clients' PC.
I am using the following code for displaying the crystal report:
Form1.loaditems()
Dim ds As New DataSet4
Dim ad As New DataSet4TableAdapters.proceduresTableAdapter
ad.Fill(ds.procedures)
Dim rpt As New CrystalReport4
rpt.SetDataSource(ds)
CrystalReportViewer1.ReportSource = rpt
For connecting VB.Net to SQL Server, I am using the following code
Imports System.Data
Imports System.Data.SqlClient
imports system.IO
Module connection
Public dbconn As SqlConnection
Public amountPaid As Integer = 0
Sub connectDatabase()
Try
dbconn = New SqlConnection("server=(localdb)\MSSQLLocalDB;AttachDbFileName=" & System.IO.Path.GetFullPath("DatabaseName.mdf") & ";Integrated Security=True;")
dbconn.Open()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Module
I think I need some way to connect the dataset with the table like
System.IO.Path.GetFullPath("DatabaseName.mdf")
and not the actual path but I don't know how to do that.
You all are requested if anyone has a solution to this problem, I shall be very thankful.
Thank you
What I have tried:
For connecting VB.Net to SQL Server, I am using the following code
<pre>Imports System.Data
Imports System.Data.SqlClient
imports system.IO
Module connection
Public dbconn As SqlConnection
Public amountPaid As Integer = 0
Sub connectDatabase()
Try
dbconn = New SqlConnection("server=(localdb)\MSSQLLocalDB;AttachDbFileName=" & System.IO.Path.GetFullPath("DatabaseName.mdf") & ";Integrated Security=True;")
dbconn.Open()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
End Module
and for displaying records on crystal report I am using the following code
Form1.loaditems()
Dim ds As New DataSet4
Dim ad As New DataSet4TableAdapters.proceduresTableAdapter
ad.Fill(ds.procedures)
Dim rpt As New CrystalReport4
rpt.SetDataSource(ds)
CrystalReportViewer1.ReportSource = rpt