首页上一页 1 下一页尾页 4 条记录 1/1页
关于水晶报表在VB中访问带有密码的ACESS数据库,提示密码无效!
发表在VB答疑区
2008-03-21
是否精华
是
否
版块置顶:
是
否
设置时间:
非永久
永久
起始时间:
结束时间:
是否扣分:
是
否
各位高手,我最近在做一个数据库的小系统,采用VB+Access来做,数据库加了密码。如果单独用水晶报表做能访问;我的数据库访问方法(如果单独访问也正常)是:<BR> ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;jet oledb:database password=" & CStr(databasepassword) & ";Persist Security Info=False"<BR>结合在一起,即在VB中用水晶报表访问带有密码的数据库就提示:密码无效[em1]
精彩评论 4
2008-03-22
沙发
<P>您好 !</P>
<P>ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "<FONT color=#ff0033>\</FONT>lsgx.mdb;jet oledb:database password=" & CStr(<FONT color=#ff0033>databasepassword</FONT>) & ";Persist Security Info=False"<BR><FONT color=#ff0066>1、请确定您的字符串(<FONT color=#ff0033>databasepassword</FONT>)是否传过来了。</FONT></P>
<P><FONT color=#ff0066>2、请确定<FONT color=#ff0033>databasepassword是否被定义的是全局变量。</FONT></FONT></P>
<P><FONT color=#ff0066>如果确定该字符串已传过来,请把其余代码发给我们,我们会尽快为您解决问题.</FONT></P>
<P>ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "<FONT color=#ff0033>\</FONT>lsgx.mdb;jet oledb:database password=" & CStr(<FONT color=#ff0033>databasepassword</FONT>) & ";Persist Security Info=False"<BR><FONT color=#ff0066>1、请确定您的字符串(<FONT color=#ff0033>databasepassword</FONT>)是否传过来了。</FONT></P>
<P><FONT color=#ff0066>2、请确定<FONT color=#ff0033>databasepassword是否被定义的是全局变量。</FONT></FONT></P>
<P><FONT color=#ff0066>如果确定该字符串已传过来,请把其余代码发给我们,我们会尽快为您解决问题.</FONT></P>
2008-03-23
板凳
<P>'查询代码</P>
<P>Public Report As New dsrXtreme<BR>Public Function ConnectString() _<BR> As String<BR> Const DatabasePassword = 888888</P>
<P>'returns a DB ConnectString<BR> 'ConnectString = "FileDSN=xtreme.dsn"<BR> 'ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\xtreme.mdb;Persist Security Info=False"<BR> 'ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;Persist Security Info=False"<BR> 'ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;jet oledb:database password=751219" & ";Persist Security Info=False"<BR> ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;jet oledb:database password=" & CStr(DatabasePassword) & ";Persist Security Info=False"<BR>MsgBox ConnectString<BR>End Function<BR>Public Function ExecuteSQL(ByVal SQL _<BR> As String, MsgString As String) _<BR> As ADODB.Recordset<BR>'executes SQL and returns Recordset<BR> Dim cnn As ADODB.Connection<BR> Dim rst As ADODB.Recordset<BR> Dim sTokens() As String<BR> <BR> On Error GoTo ExecuteSQL_Error<BR> <BR> sTokens = Split(SQL)<BR> Set cnn = New ADODB.Connection<BR> cnn.Open ConnectString<BR> If InStr("INSERT,DELETE,UPDATE,EXECUTE", _<BR> UCase$(sTokens(0))) Then<BR> cnn.Execute (SQL)<BR> MsgString = sTokens(0) & _<BR> " query successful"<BR> Else<BR> Set rst = New ADODB.Recordset<BR> rst.Open Trim$(SQL), cnn, _<BR> adOpenKeyset, _<BR> adLockOptimistic<BR> 'rst.MoveLast 'get RecordCount<BR> Set ExecuteSQL = rst<BR> MsgString = "查询到" & rst.RecordCount & _<BR> " 条记录 "<BR> End If<BR>ExecuteSQL_Exit:<BR> Set rst = Nothing<BR> Set cnn = Nothing<BR> Exit Function<BR> <BR> <BR>ExecuteSQL_Error:<BR> MsgString = "查询错误: " & _<BR> Err.Description<BR> Resume ExecuteSQL_Exit<BR>End Function<BR>'至于水晶那部分</P>
<P>Private Sub cmdCancel_Click()<BR> Unload Me<BR>End Sub</P>
<P>Private Sub cmdOK_Click()<BR> Dim txtFromD As String<BR> Dim txtToD As String</P>
<P> ' On Error GoTo cmdOK_Click_Error<BR> <BR> Dim strSelectionFormula As String<BR> Dim strSubHeading As String<BR> <BR> txtFromD = Trim(Combo1) & "-" & Trim(Combo2) & "-" & Trim(Combo3)<BR> txtToD = Trim(Combo4) & "-" & Trim(Combo5) & "-" & Trim(Combo6)<BR> <BR> <BR> 'Validate controls<BR> If Not IsDate(txtFromD) Then<BR> MsgBox "请选择报表数据开始日期!", vbOKOnly + vbCritical, "报表设计"<BR> Combo1.SetFocus<BR> Exit Sub<BR> End If 'IsNull(txtFromDate)...</P>
<P> If Not IsDate(txtToD) Then<BR> MsgBox "请选择报表数据结束日期!", vbOKOnly + vbCritical, "报表设计"<BR> Combo4.SetFocus<BR> Exit Sub<BR> End If 'IsNull(txtFromDate)...</P>
<P><BR> If OptEmail And txtAddress = "" Then<BR> MsgBox "请输入电子邮件地址", vbOKOnly + vbCritical, "报表设计"<BR> txtAddress.SetFocus<BR> Exit Sub<BR> End If 'OptEmail And IsNull(txtAddress)<BR> <BR> If CDate(txtFromD) > CDate(txtToD) Then<BR> MsgBox "结束日期必须不早于开始时间", vbOKOnly + vbCritical, "报表设计"<BR> Combo4.SetFocus<BR> Exit Sub<BR> End If 'CDate(txtFromDate) > CDate(txtToDate)<BR> <BR> Screen.MousePointer = vbHourglass<BR> Report.DiscardSavedData 'required for consistent results<BR> <BR> 'Supply record selection based on dates<BR> 'strSelectionFormula = "{Orders.Order Date} in #" & _<BR> 'txtFromD & "# to #" & txtToD & "#"<BR> strSelectionFormula = "{rcb.rq} in #" & _<BR> txtFromD & "# to #" & txtToD & "#" '要求表字段类型为日期/时间<BR> '{rcb.cph} in "4" to "京A32345"<BR> ' strSelectionFormula = "{rcb.rq} in " & _<BR> 'txtFromD & " to " & txtToD '要求表字段类型为日期/时间</P>
<P><BR> 'txtFromDate & "# to #" & txtToDate & "#"<BR> <BR> Report.RecordSelectionFormula = strSelectionFormula<BR> <BR> 'Set @Order + Tax formula<BR> Dim FormulaField As CRAXDRT.FormulaFieldDefinition<BR> Set FormulaField = Report.FormulaFields.GetItemByName("jz")<BR> <BR> ' If txtTaxRate = "" Then<BR> 'Report.FormulaFields(1).Text = "{Orders.Order Amount}"<BR> FormulaField.Text = "{rcb.mz}-" & "{rcb.pz}"<BR> 'Else<BR> 'Report.FormulaFields(1).Text = "{Orders.Order Amount} * " & Str(txtTaxRate / 100 + 1)<BR> ' FormulaField.Text = "{Orders.Order Amount} * " & Str(txtTaxRate / 100 + 1)<BR> 'End If 'txtTaxRate = ""<BR> <BR> 'Set grouping<BR> If cboGroupBy = "季度" Then<BR> Report.Areas("GH").GroupConditionField = _<BR> Report.Database.Tables(1).Fields(2) 'Orders.Order Date<BR> Report.Areas("GH").GroupCondition = crGCQuarterly '此处可以选择每日等的参数<BR> Else<BR> Report.Areas("GH").GroupConditionField = _<BR> Report.Database.Tables(1).Fields(16) 'Customer.Customer Name<BR> Report.Areas("GH").GroupCondition = crGCAnyValue<BR> End If 'cboGroupBy = "Quarter"<BR> 'Set parameter value<BR> 'Alternative method is to format details section within VB<BR> 'If txtHighlight = "" Then<BR> ' Report.ParameterFields(1).AddCurrentValue (0)<BR> 'Else<BR> ' Report.ParameterFields(1).AddCurrentValue (Val(txtHighlight))<BR> 'End If 'txtHighlight = ""<BR> <BR> 'Set grouping<BR> Report.subHeading.SetText ("aaaa")<BR> <BR> <BR> 'Hide/show sections<BR> With Report<BR> If chkSummary Then<BR> .Areas("D").HideForDrillDown = True<BR> .phb.Suppress = True<BR> .Areas("GH1").HideForDrillDown = True<BR> .gh1a.Suppress = False<BR> .gh1b.Suppress = False<BR> Else<BR> .Areas("D").HideForDrillDown = False<BR> .phb.Suppress = False<BR> .Areas("GH1").HideForDrillDown = False<BR> .gh1a.Suppress = False<BR> .gh1b.Suppress = True<BR> End If 'chkSummary<BR> End With 'Report</P>
<P><BR> If optPreview Then<BR> frmViewer.Show<BR> End If<BR> <BR> Screen.MousePointer = vbDefault<BR> Exit Sub<BR> <BR>cmdOK_Click_Error:<BR> Screen.MousePointer = vbDefault<BR> Select Case Err.Number<BR> Case -2147190889<BR> MsgBox "Report Cancelled", vbInformation, "Xtreme Order Report"<BR> Case -2147190908<BR> MsgBox "Invalid E-Mail address or other e-mail problem", vbCritical, "Xtreme Order Report"<BR> txtAddress.SetFocus<BR> Case Else<BR> MsgBox "Error " & Err.Number & " - " & Err.Description, vbCritical, "Xtreme Order Report"<BR> End Select 'Case Err.Number<BR> <BR>End Sub</P>
<P>Private Sub Form_Load()<BR> Dim mrc As ADODB.Recordset<BR> Dim txtSQL As String<BR> Dim MsgTxt As String<BR> Dim i As Integer<BR> Report.Database.Tables(1).ConnectBufferString = ConnectString<BR> 'txtFromDate = Format(#1/1/2001#, "Short Date")<BR> 'txtToDate = Format(#12/31/2001#, "Short Date")<BR> cboGroupBy.Text = "季度"<BR> <BR> ' txtSQL = "select distinct year(订单日期) from 订单"<BR> txtSQL = "select distinct year(rq) from rcb"<BR> Set mrc = ExecuteSQL(txtSQL, MsgTxt)<BR> <BR> If Not mrc.EOF Then<BR> Do While Not mrc.EOF<BR> Combo1.AddItem mrc.Fields(0)<BR> Combo4.AddItem mrc.Fields(0)<BR> mrc.MoveNext<BR> Loop<BR> End If<BR> <BR> mrc.Close<BR> <BR> For i = 1 To 12<BR> Combo2.AddItem i<BR> Combo5.AddItem i<BR> Next i<BR> <BR> For i = 1 To 31<BR> Combo3.AddItem i<BR> Combo6.AddItem i<BR> Next i<BR> <BR> Combo1.ListIndex = 0<BR> Combo4.ListIndex = 0<BR> Combo2.ListIndex = 0<BR> Combo5.ListIndex = 11<BR> Combo3.ListIndex = 0<BR> Combo6.ListIndex = 0<BR> <BR>End Sub</P>
<P>Private Sub Form_Unload(Cancel As Integer)<BR> Set Report = Nothing<BR>End Sub</P>
<P>Private Sub OptEmail_Click()<BR> txtAddress.Enabled = True<BR> lblAddress.Enabled = True<BR>End Sub</P>
<P>Private Sub optPreview_Click()<BR> txtAddress.Enabled = False<BR> lblAddress.Enabled = False<BR>End Sub</P>
<P>Private Sub OptPrint_Click()<BR> txtAddress.Enabled = False<BR> lblAddress.Enabled = False<BR>End Sub</P>
<P><BR>Private Sub txtAddress_GotFocus()<BR> txtAddress.SelStart = 0<BR> txtAddress.SelLength = Len(txtAddress)<BR>End Sub</P>
<P>Private Sub txtFromDate_GotFocus()<BR> txtFromDate.SelStart = 0<BR> txtFromDate.SelLength = Len(txtFromDate)<BR>End Sub</P>
<P>Private Sub txtFromDate_LostFocus()<BR> txtFromDate = Format(txtFromDate, "Short Date")<BR>End Sub</P>
<P>Private Sub txtHighlight_GotFocus()<BR> txtHighlight.SelStart = 0<BR> txtHighlight.SelLength = Len(txtHighlight)<BR>End Sub</P>
<P>Private Sub txtHighlight_LostFocus()<BR> If txtHighlight <> "" Then<BR> txtHighlight = Val(txtHighlight)<BR> End If 'txtHighlight <> ""<BR>End Sub</P>
<P>Private Sub txtTaxRate_GotFocus()<BR> txtTaxRate.SelStart = 0<BR> txtTaxRate.SelLength = Len(txtTaxRate)<BR>End Sub</P>
<P>Private Sub txtTaxRate_LostFocus()<BR> If txtTaxRate <> "" Then<BR> txtTaxRate = Val(txtTaxRate)<BR> End If 'txtTaxRate <> ""<BR>End Sub</P>
<P>Private Sub txtToDate_GotFocus()<BR> txtToDate.SelStart = 0<BR> txtToDate.SelLength = Len(txtToDate)<BR>End Sub</P>
<P>Private Sub txtToDate_LostFocus()<BR> txtToDate = Format(txtToDate, "Short Date")<BR>End Sub<BR></P>
<P>打开水晶报表建立的窗体然后在"FROM_LOAD"中加入下面的语句,并在"="号后面写上登录数据库使用的连接字串,用户名与密码写在登录字串中<BR>Report.Database.Tables(1).ConnectBufferString ="........."</P>
<P>为什么我加了代码还是说我“未指定数据库”呢?<BR></P>
<P>Public Report As New dsrXtreme<BR>Public Function ConnectString() _<BR> As String<BR> Const DatabasePassword = 888888</P>
<P>'returns a DB ConnectString<BR> 'ConnectString = "FileDSN=xtreme.dsn"<BR> 'ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\xtreme.mdb;Persist Security Info=False"<BR> 'ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;Persist Security Info=False"<BR> 'ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;jet oledb:database password=751219" & ";Persist Security Info=False"<BR> ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\lsgx.mdb;jet oledb:database password=" & CStr(DatabasePassword) & ";Persist Security Info=False"<BR>MsgBox ConnectString<BR>End Function<BR>Public Function ExecuteSQL(ByVal SQL _<BR> As String, MsgString As String) _<BR> As ADODB.Recordset<BR>'executes SQL and returns Recordset<BR> Dim cnn As ADODB.Connection<BR> Dim rst As ADODB.Recordset<BR> Dim sTokens() As String<BR> <BR> On Error GoTo ExecuteSQL_Error<BR> <BR> sTokens = Split(SQL)<BR> Set cnn = New ADODB.Connection<BR> cnn.Open ConnectString<BR> If InStr("INSERT,DELETE,UPDATE,EXECUTE", _<BR> UCase$(sTokens(0))) Then<BR> cnn.Execute (SQL)<BR> MsgString = sTokens(0) & _<BR> " query successful"<BR> Else<BR> Set rst = New ADODB.Recordset<BR> rst.Open Trim$(SQL), cnn, _<BR> adOpenKeyset, _<BR> adLockOptimistic<BR> 'rst.MoveLast 'get RecordCount<BR> Set ExecuteSQL = rst<BR> MsgString = "查询到" & rst.RecordCount & _<BR> " 条记录 "<BR> End If<BR>ExecuteSQL_Exit:<BR> Set rst = Nothing<BR> Set cnn = Nothing<BR> Exit Function<BR> <BR> <BR>ExecuteSQL_Error:<BR> MsgString = "查询错误: " & _<BR> Err.Description<BR> Resume ExecuteSQL_Exit<BR>End Function<BR>'至于水晶那部分</P>
<P>Private Sub cmdCancel_Click()<BR> Unload Me<BR>End Sub</P>
<P>Private Sub cmdOK_Click()<BR> Dim txtFromD As String<BR> Dim txtToD As String</P>
<P> ' On Error GoTo cmdOK_Click_Error<BR> <BR> Dim strSelectionFormula As String<BR> Dim strSubHeading As String<BR> <BR> txtFromD = Trim(Combo1) & "-" & Trim(Combo2) & "-" & Trim(Combo3)<BR> txtToD = Trim(Combo4) & "-" & Trim(Combo5) & "-" & Trim(Combo6)<BR> <BR> <BR> 'Validate controls<BR> If Not IsDate(txtFromD) Then<BR> MsgBox "请选择报表数据开始日期!", vbOKOnly + vbCritical, "报表设计"<BR> Combo1.SetFocus<BR> Exit Sub<BR> End If 'IsNull(txtFromDate)...</P>
<P> If Not IsDate(txtToD) Then<BR> MsgBox "请选择报表数据结束日期!", vbOKOnly + vbCritical, "报表设计"<BR> Combo4.SetFocus<BR> Exit Sub<BR> End If 'IsNull(txtFromDate)...</P>
<P><BR> If OptEmail And txtAddress = "" Then<BR> MsgBox "请输入电子邮件地址", vbOKOnly + vbCritical, "报表设计"<BR> txtAddress.SetFocus<BR> Exit Sub<BR> End If 'OptEmail And IsNull(txtAddress)<BR> <BR> If CDate(txtFromD) > CDate(txtToD) Then<BR> MsgBox "结束日期必须不早于开始时间", vbOKOnly + vbCritical, "报表设计"<BR> Combo4.SetFocus<BR> Exit Sub<BR> End If 'CDate(txtFromDate) > CDate(txtToDate)<BR> <BR> Screen.MousePointer = vbHourglass<BR> Report.DiscardSavedData 'required for consistent results<BR> <BR> 'Supply record selection based on dates<BR> 'strSelectionFormula = "{Orders.Order Date} in #" & _<BR> 'txtFromD & "# to #" & txtToD & "#"<BR> strSelectionFormula = "{rcb.rq} in #" & _<BR> txtFromD & "# to #" & txtToD & "#" '要求表字段类型为日期/时间<BR> '{rcb.cph} in "4" to "京A32345"<BR> ' strSelectionFormula = "{rcb.rq} in " & _<BR> 'txtFromD & " to " & txtToD '要求表字段类型为日期/时间</P>
<P><BR> 'txtFromDate & "# to #" & txtToDate & "#"<BR> <BR> Report.RecordSelectionFormula = strSelectionFormula<BR> <BR> 'Set @Order + Tax formula<BR> Dim FormulaField As CRAXDRT.FormulaFieldDefinition<BR> Set FormulaField = Report.FormulaFields.GetItemByName("jz")<BR> <BR> ' If txtTaxRate = "" Then<BR> 'Report.FormulaFields(1).Text = "{Orders.Order Amount}"<BR> FormulaField.Text = "{rcb.mz}-" & "{rcb.pz}"<BR> 'Else<BR> 'Report.FormulaFields(1).Text = "{Orders.Order Amount} * " & Str(txtTaxRate / 100 + 1)<BR> ' FormulaField.Text = "{Orders.Order Amount} * " & Str(txtTaxRate / 100 + 1)<BR> 'End If 'txtTaxRate = ""<BR> <BR> 'Set grouping<BR> If cboGroupBy = "季度" Then<BR> Report.Areas("GH").GroupConditionField = _<BR> Report.Database.Tables(1).Fields(2) 'Orders.Order Date<BR> Report.Areas("GH").GroupCondition = crGCQuarterly '此处可以选择每日等的参数<BR> Else<BR> Report.Areas("GH").GroupConditionField = _<BR> Report.Database.Tables(1).Fields(16) 'Customer.Customer Name<BR> Report.Areas("GH").GroupCondition = crGCAnyValue<BR> End If 'cboGroupBy = "Quarter"<BR> 'Set parameter value<BR> 'Alternative method is to format details section within VB<BR> 'If txtHighlight = "" Then<BR> ' Report.ParameterFields(1).AddCurrentValue (0)<BR> 'Else<BR> ' Report.ParameterFields(1).AddCurrentValue (Val(txtHighlight))<BR> 'End If 'txtHighlight = ""<BR> <BR> 'Set grouping<BR> Report.subHeading.SetText ("aaaa")<BR> <BR> <BR> 'Hide/show sections<BR> With Report<BR> If chkSummary Then<BR> .Areas("D").HideForDrillDown = True<BR> .phb.Suppress = True<BR> .Areas("GH1").HideForDrillDown = True<BR> .gh1a.Suppress = False<BR> .gh1b.Suppress = False<BR> Else<BR> .Areas("D").HideForDrillDown = False<BR> .phb.Suppress = False<BR> .Areas("GH1").HideForDrillDown = False<BR> .gh1a.Suppress = False<BR> .gh1b.Suppress = True<BR> End If 'chkSummary<BR> End With 'Report</P>
<P><BR> If optPreview Then<BR> frmViewer.Show<BR> End If<BR> <BR> Screen.MousePointer = vbDefault<BR> Exit Sub<BR> <BR>cmdOK_Click_Error:<BR> Screen.MousePointer = vbDefault<BR> Select Case Err.Number<BR> Case -2147190889<BR> MsgBox "Report Cancelled", vbInformation, "Xtreme Order Report"<BR> Case -2147190908<BR> MsgBox "Invalid E-Mail address or other e-mail problem", vbCritical, "Xtreme Order Report"<BR> txtAddress.SetFocus<BR> Case Else<BR> MsgBox "Error " & Err.Number & " - " & Err.Description, vbCritical, "Xtreme Order Report"<BR> End Select 'Case Err.Number<BR> <BR>End Sub</P>
<P>Private Sub Form_Load()<BR> Dim mrc As ADODB.Recordset<BR> Dim txtSQL As String<BR> Dim MsgTxt As String<BR> Dim i As Integer<BR> Report.Database.Tables(1).ConnectBufferString = ConnectString<BR> 'txtFromDate = Format(#1/1/2001#, "Short Date")<BR> 'txtToDate = Format(#12/31/2001#, "Short Date")<BR> cboGroupBy.Text = "季度"<BR> <BR> ' txtSQL = "select distinct year(订单日期) from 订单"<BR> txtSQL = "select distinct year(rq) from rcb"<BR> Set mrc = ExecuteSQL(txtSQL, MsgTxt)<BR> <BR> If Not mrc.EOF Then<BR> Do While Not mrc.EOF<BR> Combo1.AddItem mrc.Fields(0)<BR> Combo4.AddItem mrc.Fields(0)<BR> mrc.MoveNext<BR> Loop<BR> End If<BR> <BR> mrc.Close<BR> <BR> For i = 1 To 12<BR> Combo2.AddItem i<BR> Combo5.AddItem i<BR> Next i<BR> <BR> For i = 1 To 31<BR> Combo3.AddItem i<BR> Combo6.AddItem i<BR> Next i<BR> <BR> Combo1.ListIndex = 0<BR> Combo4.ListIndex = 0<BR> Combo2.ListIndex = 0<BR> Combo5.ListIndex = 11<BR> Combo3.ListIndex = 0<BR> Combo6.ListIndex = 0<BR> <BR>End Sub</P>
<P>Private Sub Form_Unload(Cancel As Integer)<BR> Set Report = Nothing<BR>End Sub</P>
<P>Private Sub OptEmail_Click()<BR> txtAddress.Enabled = True<BR> lblAddress.Enabled = True<BR>End Sub</P>
<P>Private Sub optPreview_Click()<BR> txtAddress.Enabled = False<BR> lblAddress.Enabled = False<BR>End Sub</P>
<P>Private Sub OptPrint_Click()<BR> txtAddress.Enabled = False<BR> lblAddress.Enabled = False<BR>End Sub</P>
<P><BR>Private Sub txtAddress_GotFocus()<BR> txtAddress.SelStart = 0<BR> txtAddress.SelLength = Len(txtAddress)<BR>End Sub</P>
<P>Private Sub txtFromDate_GotFocus()<BR> txtFromDate.SelStart = 0<BR> txtFromDate.SelLength = Len(txtFromDate)<BR>End Sub</P>
<P>Private Sub txtFromDate_LostFocus()<BR> txtFromDate = Format(txtFromDate, "Short Date")<BR>End Sub</P>
<P>Private Sub txtHighlight_GotFocus()<BR> txtHighlight.SelStart = 0<BR> txtHighlight.SelLength = Len(txtHighlight)<BR>End Sub</P>
<P>Private Sub txtHighlight_LostFocus()<BR> If txtHighlight <> "" Then<BR> txtHighlight = Val(txtHighlight)<BR> End If 'txtHighlight <> ""<BR>End Sub</P>
<P>Private Sub txtTaxRate_GotFocus()<BR> txtTaxRate.SelStart = 0<BR> txtTaxRate.SelLength = Len(txtTaxRate)<BR>End Sub</P>
<P>Private Sub txtTaxRate_LostFocus()<BR> If txtTaxRate <> "" Then<BR> txtTaxRate = Val(txtTaxRate)<BR> End If 'txtTaxRate <> ""<BR>End Sub</P>
<P>Private Sub txtToDate_GotFocus()<BR> txtToDate.SelStart = 0<BR> txtToDate.SelLength = Len(txtToDate)<BR>End Sub</P>
<P>Private Sub txtToDate_LostFocus()<BR> txtToDate = Format(txtToDate, "Short Date")<BR>End Sub<BR></P>
<P>打开水晶报表建立的窗体然后在"FROM_LOAD"中加入下面的语句,并在"="号后面写上登录数据库使用的连接字串,用户名与密码写在登录字串中<BR>Report.Database.Tables(1).ConnectBufferString ="........."</P>
<P>为什么我加了代码还是说我“未指定数据库”呢?<BR></P>