Click here to Skip to main content
15,884,042 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello friends

I have made an medical app in vb.net 2008 and my back hand is sql server 2008? My problem is when i try to run my crystal report i have no problem when it is for single table.But for two table it shows me sql error and asking me login id and password?I have attached my code for your refrence.

CODE BEGINS:---
-------------------------------------------------------------------
Frm bill_print code dynamically
------------------------------------------------------------------
Imports System.Data.SqlClient
Imports System.Data
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

Public Class frmbillprint

Private Sub frmbillprint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
connectdb()
Dim ad As New SqlDataAdapter("Select * from sales_invoice", cn)
Dim ds As New DataSet
ds.Clear()
ad.Fill(ds, "sales_invoice")
Dim strReportPath As String = pth & "\billprint.rpt"
Dim cr As New ReportDocument()
cr.Load(strReportPath)
cr.SetDataSource(ds.Tables("sales_invoice"))
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.ReportSource = cr
End Sub


End Class
------------------------------------------------------------------------
It contain database Sales_invoice and Sales_details
Sales_invoice--(bilno,billdat,so_id,cust_code,cust_name,amount,vat,net_amount)
sales_details---(medi_code,qty,amt)

-------------------------------------------------------------------------
It show me error

Database Login
Ask every time for login id and password
___________________________________________________________________________

Friends plz help me out.....
Posted

1 solution

add following line in your code
VB
cr.SetDatabaseLogon(loginid, password)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900