|
Hi, can anyone help give me the sample code on how to display the record from access or sql server on crystal report in vb.net 2003?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Here is the way how to Display records on Crystal report from SQL Server. Suppose You have a database with the name MyDatabase which contains many tables and you want to display records from table1 . To do so you've to follow these steps
1) First Create a new form Say MyReportForm then add
Crytalreportviewer from toolbox
2) Now suppose you want to show the roport when user clicks the Report button .Add follwing lines at top of the form which contains Report button
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
3)Write the following code in the click event for Report button .
Dim FRM As New MyReportForm
Dim rpt As New MyReport
try
Dim LogInfo As New TableLogOnInfo()
Dim LogInfos As New TableLogOnInfos()
LogInfo.ConnectionInfo.ServerName = "."
LogInfo.ConnectionInfo.DatabaseName = "MyDatabase"
LogInfo.ConnectionInfo.UserID = "MyUserName"
LogInfo.ConnectionInfo.Password = "Mypassword"
LogInfos.Add(LogInfo)
rpt.Refresh()
FRM.CrystalReportViewer1.LogOnInfo = LogInfos
( FRM.CrystalReportViewer1.SelectionFormula = "{Table1.SomeField} = " & SomeCriteria & " " )
FRM.CrystalReportViewer1.ReportSource = rpt
catch ex as exception
msgbox(ex.Message & ex.stackTrace)
End Try
Note that Statement in paranthesis is optional only if you want to show records by filtering on the basis of some criteria.
|
|
|
|
|
Thank you very much for your answer. But I have a problem with
TheOnlyFalcon wrote:
Dim rpt As New MyReport
this line and
TheOnlyFalcon wrote:
FRM.CrystalReportViewer1.LogOnInfo = LogInfos
( FRM.CrystalReportViewer1.SelectionFormula = "{Table1.SomeField} = " & SomeCriteria & " " )
this line.
The first one is not recognized by the vs.net. It appear the blue line under it. The second one is not correct. Can you give some more reallity example?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Oops!!!!!!!!! Two problems
Your first problem is becuase you may have not added a report to your project to do so from solution explorer right click your project then select add new item from the dialog box selec crystalreport and assign it any suitable name "MyReport" in this case VS.NET will create a class for your report.
Your second problem is because you may not have added a crystal report viewer add it from toolbox if you have still problems then contact me at cyberboy_137@hotmail.com
Many regards
|
|
|
|
|
Thank you very much for your comment. I have correct the problem and the code could run without any error. But there is nothing appear on the screen. Here is my code that I used:
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim FRM As New MyReportForm
Dim rpt As New MyReport
Try
Dim LogInfo As New TableLogOnInfo
Dim LogInfos As New TableLogOnInfos
LogInfo.ConnectionInfo.ServerName = "."
LogInfo.ConnectionInfo.DatabaseName = "VSA"
LogInfo.ConnectionInfo.UserID = "kanel"
LogInfo.ConnectionInfo.Password = "scn-co"
LogInfos.Add(LogInfo)
rpt.Refresh()
FRM.CrystalReportViewer1.LogOnInfo = LogInfos
FRM.CrystalReportViewer1.SelectionFormula = _
"{tblAnalysesChildCase.ChildName} = 'eQOn eGOn'" ' & SomeCriteria & " ")
FRM.CrystalReportViewer1.ReportSource = rpt
FRM.CrystalReportViewer1.Show()
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
End Try
End Sub
Thank for your help!!
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
The problem might be the case of following line .
FRM.CrystalReportViewer1.SelectionFormula = _ "{tblAnalysesChildCase.ChildName} = 'eQOn eGOn'" ' & SomeCriteria & " ")
Actualy this will be interpreted as like a WHERE clause so
if you want to show filtered data on report then you have to use "Correct selelectionFormula" Here i can see you have not written the proper selection formula .
Example
Suppose you want to show the records of those whose ages are under 12 and you have combobox named "cboages" filled with ages of children and the daatbase field is "Child_Age" .Select 12 from cboages then click Button1 or whatever your button name is .
frm.crystalreportviewer1.SelectionFormula="{tblAnalysisChildcase.Child_Age}= " & cboages.text & " "
And to filter data on the basis of some text not numberic value use single quotes
Example
Show records for Allen
you have a textbox named txtname
Enter Allen then click your button .
frm.crystalreportviewer1.SelectionFormula="{tblAnalysisChildcase.ChildName}= '" & txtName.text & "' "
Your problem must be solved now , if there are still problems you can contact me
Bye
|
|
|
|
|
Hello all,
Does anybody have any idea how to detect mdb files. I really need some advice here. Maybe i should briefly explain what i am doing now.
I am working on this program where i have to print a report for Buyer's Info, Buyer's Label, Supplier's Info and Supplier's Label. Both Buyer & Supplier have a seperate database (SA1.mdb & SA2.mdb). I have created a form with two listbox. The first listbox will load & display the number of mdb files i have in the project folder. In this case i have two (SA1 and SA2). When i select either one from the first listbox, lets say SA1 which is the database for Buyer, the second listbox will then display Buyer Info & Buyer Label vice versa. Then when i select either one of them from the second listbox and proceed to the generate report button, the report will be printed accordingly.
Hmm... does anybody know how to do that? really looking forward to an answer. Thank you!
|
|
|
|
|
VB6 or VB.NET ? In VB.NET you can use Directory.FindFiles, which takes a filter, so you can get an array of filenames that end in .mdb.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello everyone,
Can i delete a file forcefully at the time when that file is in use by another process.
Thanks.
|
|
|
|
|
To remove a file that is in use by another process, you have to kill the process that has the file open.
Example:
Public Sub TermProc(byval procname as string)
Dim processes() As Process
Dim proc As Process
processes = Process.GetProcesses
For Each proc In processes
If proc.ProcessName.ToLower = procname Then
Try
proc.Kill()
Exit For
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End If
Next
End Sub
Then you could remove the file.
System.IO.File.Delete(path)
|
|
|
|
|
Is there any way to keep that process running and just break the access of that process with that file.
Because that process is of my application. I'm working on some project in which i have to create lot of temporary files and then i need to delete also. Sometimes in a very rare case my application process don't stop accessing some of the files so that i cannot delete those file unless i will close my application.
What do u suggest about it.
|
|
|
|
|
You do not need to figure out how to delete the file, instead you need to figure out what is wrong with your existing code. Because something is certainly wrong!
You are trying to use the wrong approach to fix what basically amounts to a bug.
If a file is open because the application needs it, and another function in the same application tries to delete that file, then obviously there is a bug in your temp file deletion operation.
If there is no bug in the file deletion algorithm, i.e. you know for sure that it never tries to delete files that are stil needed, then you have a file that is no longer needed but cannot be deleted because it is still open. In that case the bug is in your opening and closing of temp files.
Either way it is a bug, period.
Rather than trying to write additional code to force the delete of a file that is "in use" you need to carefully reveiw your existing code and determine what this set of conditions ever arises in the firtrst place.
Robert
|
|
|
|
|
No, you can't. If your process doesn't own the handle to the file, you can't get at it. This would be a security violation.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am receiving this error when i try to update the database. the grid works fine untill i try to update the values---
Here is the errr===================
Server Error in '/DataBaseUpdate' Application.
--------------------------------------------------------------------------------
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 87: Dim RestrictTen As String = CType(e.Item.Cells(16).Controls(0), TextBox).Text
Line 88: Dim RestrictEleven As String = CType(e.Item.Cells(17).Controls(0), TextBox).Text
Line 89: Dim RestrictTwelve As String = CType(e.Item.Cells(18).Controls(0), TextBox).Text
Line 90: '
Line 91: 'Get the connection
Source File: c:\inetpub\wwwroot\DataBaseUpdate\UpdateProducts.aspx.vb Line: 89
Stack Trace:
=========Here is the update section of the code--------------------
'UpDate OnClick This Fires
'
Sub dgProducts_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
'
'Read in the values of the updated row
'ID'S
Dim IDProductRestrictions As Integer = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim IDProduct As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Text
'ID'S
Dim MaxiumWidth As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim MaxiumLength As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim MinimumWidthForLiftTilt As String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim InsideMount As String = CType(e.Item.Cells(6).Controls(0), TextBox).Text
Dim OutsideMount As String = CType(e.Item.Cells(7).Controls(0), TextBox).Text
Dim ControlTilt As String = CType(e.Item.Cells(8).Controls(0), TextBox).Text
Dim StackingFormulas As String = CType(e.Item.Cells(9).Controls(0), TextBox).Text
Dim RestrictFive As String = CType(e.Item.Cells(10).Controls(0), TextBox).Text
Dim RestrictiveSix As String = CType(e.Item.Cells(11).Controls(0), TextBox).Text
Dim RestrictSeven As String = CType(e.Item.Cells(12).Controls(0), TextBox).Text
Dim RestrictEight As String = CType(e.Item.Cells(14).Controls(0), TextBox).Text
Dim RestrictNine As String = CType(e.Item.Cells(15).Controls(0), TextBox).Text
Dim RestrictTen As String = CType(e.Item.Cells(16).Controls(0), TextBox).Text
Dim RestrictEleven As String = CType(e.Item.Cells(17).Controls(0), TextBox).Text
Dim RestrictTwelve As String = CType(e.Item.Cells(18).Controls(0), TextBox).Text
'
'Get the connection
'
Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings("cnn"))
cnn.Open()
'
'Set the command
'
Dim myCommand As New SqlCommand("SprocInsertProductRestrictive", cnn)
myCommand.CommandType = CommandType.StoredProcedure
'
'Add Parameters to the SQL query
'
Dim paramIDProductRestrictions As SqlParameter = New SqlParameter("@IDProductRestrictions", SqlDbType.Int, 4)
paramIDProductRestrictions.Value = IDProductRestrictions
myCommand.Parameters.Add(paramIDProductRestrictions)
'
Dim paramIDProduct As SqlParameter = New SqlParameter("@IDProduct", SqlDbType.Int, 4)
paramIDProduct.Value = IDProduct
myCommand.Parameters.Add(paramIDProduct)
'
Dim paramMaxiumWidth As SqlParameter = New SqlParameter("@MaxiumWidth", SqlDbType.VarChar, 3800)
paramMaxiumWidth.Value = MaxiumWidth
myCommand.Parameters.Add(paramMaxiumWidth)
'
Dim paramMaxiumLength As SqlParameter = New SqlParameter("@MaxiumLength", SqlDbType.VarChar, 3800)
paramMaxiumLength.Value = MaxiumLength
myCommand.Parameters.Add(paramMaxiumLength)
'
Dim paramMinimumWidthForLiftTilt As SqlParameter = New SqlParameter("@MinimumWidthForLiftTilt", SqlDbType.VarChar, 3800)
paramMinimumWidthForLiftTilt.Value = MinimumWidthForLiftTilt
myCommand.Parameters.Add(paramMinimumWidthForLiftTilt)
'
Dim paramInsideMount As SqlParameter = New SqlParameter("@InsideMount", SqlDbType.VarChar, 3800)
paramInsideMount.Value = InsideMount
myCommand.Parameters.Add(paramInsideMount)
'
Dim paramOutsideMount As SqlParameter = New SqlParameter("@OutsideMount", SqlDbType.VarChar, 3800)
paramOutsideMount.Value = OutsideMount
myCommand.Parameters.Add(paramOutsideMount)
'
Dim paramControlTilt As SqlParameter = New SqlParameter("@ControlTilt", SqlDbType.VarChar, 3800)
paramControlTilt.Value = ControlTilt
myCommand.Parameters.Add(paramControlTilt)
'
Dim paramStackingFormulas As SqlParameter = New SqlParameter("@StackingFormulas", SqlDbType.VarChar, 3800)
paramStackingFormulas.Value = StackingFormulas
myCommand.Parameters.Add(paramStackingFormulas)
'
Dim paramRestrictFive As SqlParameter = New SqlParameter("@RestrictFive", SqlDbType.VarChar, 3800)
paramRestrictFive.Value = RestrictFive
myCommand.Parameters.Add(paramRestrictFive)
'
Dim paramRestrictSix As SqlParameter = New SqlParameter("@RestrictSix", SqlDbType.VarChar, 3800)
paramRestrictSix.Value = RestrictiveSix
myCommand.Parameters.Add(paramRestrictSix)
'
Dim paramRestrictSeven As SqlParameter = New SqlParameter("@RestrictSeven", SqlDbType.VarChar, 3800)
paramRestrictSeven.Value = RestrictSeven
myCommand.Parameters.Add(paramRestrictSeven)
'
Dim paramRestrictEight As SqlParameter = New SqlParameter("@RestrictEight", SqlDbType.VarChar, 3800)
paramRestrictEight.Value = RestrictEight
myCommand.Parameters.Add(paramRestrictEight)
'
Dim paramRestrictNine As SqlParameter = New SqlParameter("@RestrictNine", SqlDbType.VarChar, 3800)
paramRestrictNine.Value = RestrictNine
myCommand.Parameters.Add(paramRestrictNine)
'
Dim paramRestrictTen As SqlParameter = New SqlParameter("@RestrictTen", SqlDbType.VarChar, 3800)
paramRestrictTen.Value = RestrictTen
myCommand.Parameters.Add(paramRestrictTen)
'
Dim paramRestrictEleven As SqlParameter = New SqlParameter("@RestrictEleven", SqlDbType.VarChar, 3800)
paramRestrictEleven.Value = RestrictEleven
myCommand.Parameters.Add(paramRestrictEleven)
'
Dim paramRestrictTwelve As SqlParameter = New SqlParameter("@RestrictTwelve", SqlDbType.VarChar, 3800)
paramRestrictTwelve.Value = RestrictTwelve
myCommand.Parameters.Add(paramRestrictTwelve)
'
myCommand.ExecuteNonQuery() 'Execute the UPDATE query
'
cnn.Close()
'
'Finally, set the EditItemIndex to -1 and rebind the DataGrid
'
dgUpdateProductRestrictions.EditItemIndex = -1
BindData()
End Sub
End Class
============Thank you.....................
Erik...
|
|
|
|
|
I see a couple of things to check.
1) The error message indicates that an indexed value such as an array is out of bounds.
2) The e.grid.cells if I recall correctly starts indexes as 0. On your line:
Dim RestrictTwelve As String = CType(e.Item.Cells(18).Controls(0), TextBox).Text
May be throwing the error as this could be out of bounds of there are only 18 items in grid.
Hope this helps....
|
|
|
|
|
i have restructured my code starting the cell index at (1) because of the edit button in the first cell. Now i am receive this error message.
I am not sure if this will help you any but my grid is displaying double for some reason. I have not had trouble with populating datalist and grids untill now with the edit situation and i have been on thid for 2 days, Making me loco
any suggestions at all to what i am doing wrong here... I WILL POST MY CODE AGAIN
Server Error in '/DataBaseUpdate' Application.
--------------------------------------------------------------------------------
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 72: 'ID'S
Line 73: Dim IDProductRestrictions As Integer = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Line 74: Dim IDProduct As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Line 75: 'ID'S
Line 76: Dim MaxiumWidth As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
====================Update============================================
Sub dgProducts_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
'
'Read in the values of the updated row
'ID'S
Dim IDProductRestrictions As Integer = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim IDProduct As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Text
'ID'S
Dim MaxiumWidth As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim MaxiumLength As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim MinimumWidthForLiftTilt As String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim InsideMount As String = CType(e.Item.Cells(6).Controls(0), TextBox).Text
Dim OutsideMount As String = CType(e.Item.Cells(7).Controls(0), TextBox).Text
Dim ControlTilt As String = CType(e.Item.Cells(8).Controls(0), TextBox).Text
Dim StackingFormulas As String = CType(e.Item.Cells(9).Controls(0), TextBox).Text
Dim RestrictFive As String = CType(e.Item.Cells(10).Controls(0), TextBox).Text
Dim RestrictSix As String = CType(e.Item.Cells(11).Controls(0), TextBox).Text
Dim RestrictSeven As String = CType(e.Item.Cells(12).Controls(0), TextBox).Text
Dim RestrictEight As String = CType(e.Item.Cells(13).Controls(0), TextBox).Text
Dim RestrictNine As String = CType(e.Item.Cells(14).Controls(0), TextBox).Text
Dim RestrictTen As String = CType(e.Item.Cells(15).Controls(0), TextBox).Text
Dim RestrictEleven As String = CType(e.Item.Cells(16).Controls(0), TextBox).Text
Dim RestrictTwelve As String = CType(e.Item.Cells(17).Controls(0), TextBox).Text
'
'Get the connection
'
Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings("cnn"))
cnn.Open()
'
'Set the command
'
Dim myCommand As New SqlCommand("SprocInsertProductRestrictive", cnn)
myCommand.CommandType = CommandType.StoredProcedure
'
'Add Parameters to the SQL query
'
Dim paramIDProductRestrictions As SqlParameter = New SqlParameter("@IDProductRestrictions", SqlDbType.Int, 4)
paramIDProductRestrictions.Value = IDProductRestrictions
myCommand.Parameters.Add(paramIDProductRestrictions)
'
Dim paramIDProduct As SqlParameter = New SqlParameter("@IDProduct", SqlDbType.Int, 4)
paramIDProduct.Value = IDProduct
myCommand.Parameters.Add(paramIDProduct)
'
Dim paramMaxiumWidth As SqlParameter = New SqlParameter("@MaxiumWidth", SqlDbType.VarChar, 3800)
paramMaxiumWidth.Value = MaxiumWidth
myCommand.Parameters.Add(paramMaxiumWidth)
'
Dim paramMaxiumLength As SqlParameter = New SqlParameter("@MaxiumLength", SqlDbType.VarChar, 3800)
paramMaxiumLength.Value = MaxiumLength
myCommand.Parameters.Add(paramMaxiumLength)
'
Dim paramMinimumWidthForLiftTilt As SqlParameter = New SqlParameter("@MinimumWidthForLiftTilt", SqlDbType.VarChar, 3800)
paramMinimumWidthForLiftTilt.Value = MinimumWidthForLiftTilt
myCommand.Parameters.Add(paramMinimumWidthForLiftTilt)
'
Dim paramInsideMount As SqlParameter = New SqlParameter("@InsideMount", SqlDbType.VarChar, 3800)
paramInsideMount.Value = InsideMount
myCommand.Parameters.Add(paramInsideMount)
'
Dim paramOutsideMount As SqlParameter = New SqlParameter("@OutsideMount", SqlDbType.VarChar, 3800)
paramOutsideMount.Value = OutsideMount
myCommand.Parameters.Add(paramOutsideMount)
'
Dim paramControlTilt As SqlParameter = New SqlParameter("@ControlTilt", SqlDbType.VarChar, 3800)
paramControlTilt.Value = ControlTilt
myCommand.Parameters.Add(paramControlTilt)
'
Dim paramStackingFormulas As SqlParameter = New SqlParameter("@StackingFormulas", SqlDbType.VarChar, 3800)
paramStackingFormulas.Value = StackingFormulas
myCommand.Parameters.Add(paramStackingFormulas)
'
Dim paramRestrictFive As SqlParameter = New SqlParameter("@RestrictFive", SqlDbType.VarChar, 3800)
paramRestrictFive.Value = RestrictFive
myCommand.Parameters.Add(paramRestrictFive)
'
Dim paramRestrictSix As SqlParameter = New SqlParameter("@RestrictSix", SqlDbType.VarChar, 3800)
paramRestrictSix.Value = RestrictSix
myCommand.Parameters.Add(paramRestrictSix)
'
Dim paramRestrictSeven As SqlParameter = New SqlParameter("@RestrictSeven", SqlDbType.VarChar, 3800)
paramRestrictSeven.Value = RestrictSeven
myCommand.Parameters.Add(paramRestrictSeven)
'
Dim paramRestrictEight As SqlParameter = New SqlParameter("@RestrictEight", SqlDbType.VarChar, 3800)
paramRestrictEight.Value = RestrictEight
myCommand.Parameters.Add(paramRestrictEight)
'
Dim paramRestrictNine As SqlParameter = New SqlParameter("@RestrictNine", SqlDbType.VarChar, 3800)
paramRestrictNine.Value = RestrictNine
myCommand.Parameters.Add(paramRestrictNine)
'
Dim paramRestrictTen As SqlParameter = New SqlParameter("@RestrictTen", SqlDbType.VarChar, 3800)
paramRestrictTen.Value = RestrictTen
myCommand.Parameters.Add(paramRestrictTen)
'
Dim paramRestrictEleven As SqlParameter = New SqlParameter("@RestrictEleven", SqlDbType.VarChar, 3800)
paramRestrictEleven.Value = RestrictEleven
myCommand.Parameters.Add(paramRestrictEleven)
'
Dim paramRestrictTwelve As SqlParameter = New SqlParameter("@RestrictTwelve", SqlDbType.VarChar, 3800)
paramRestrictTwelve.Value = RestrictTwelve
myCommand.Parameters.Add(paramRestrictTwelve)
'
myCommand.ExecuteNonQuery() 'Execute the UPDATE query
'
cnn.Close()
'
'Finally, set the EditItemIndex to -1 and rebind the DataGrid
'
dgUpdateProductRestrictions.EditItemIndex = -1
BindData()
End Sub
End Class
=====================Grid----------------
<asp:datagrid id="dgUpdateProductRestrictions" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 8px"
="" runat="server" oneditcommand="dgProducts_Edit" oncancelcommand="dgProducts_Cancel" onupdatecommand="dgProducts_Update">
<footerstyle backcolor="Tan">
<selecteditemstyle forecolor="GhostWhite" backcolor="DarkSlateBlue">
<alternatingitemstyle backcolor="PaleGoldenrod">
<itemstyle wrap="False">
<headerstyle backcolor="#99CCCC">
<columns>
<asp:editcommandcolumn buttontype="PushButton" updatetext="Update" canceltext="Cancel" edittext="Edit Info">
<asp:boundcolumn datafield="ProductRestrictionsID" headertext="ProductRestrictionsID">
<asp:boundcolumn datafield="ProductID" readonly="True" headertext="ProductID">
<asp:boundcolumn datafield="MaximumWidth" headertext="MaxiumWidth">
<asp:boundcolumn datafield="MaximumLength" headertext="MaxiumLength">
<asp:boundcolumn datafield="MinimumWidthForLiftTilt" headertext="MinimumWidthForLiftTilt">
<asp:boundcolumn datafield="InsideMount" headertext="InsideMount">
<asp:boundcolumn datafield="OutsideMount" headertext="OutsideMount">
<asp:boundcolumn datafield="ControlTilt" headertext="ControlTilt">
<asp:boundcolumn datafield="StackingFormulas" headertext="StackingFormulas">
<asp:boundcolumn datafield="RestrictFive" headertext="RestrictFive">
<asp:boundcolumn datafield="RestrictSix" headertext="RestrictSix">
<asp:boundcolumn datafield="RestrictSeven" headertext="RestrictSeven">
<asp:boundcolumn datafield="RestrictEight" headertext="RestrictEight">
<asp:boundcolumn datafield="RestrictNine" headertext="RestrictNine">
<asp:boundcolumn datafield="RestrictTen" headertext="RestrictTen">
<asp:boundcolumn datafield="RestrictEleven" headertext="RestrictEleven">
<asp:boundcolumn datafield="RestrictTwelve" headertext="RestrictTwelve">
|
|
|
|
|
Ok i finally got everything to work with no errors, only now when i fill in the new data and Press UPDATE the database does not update.
Anyone can help me one this one?
Thanks in advance...
ERIK....
Here is my code============
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Sub BindData()
'
'1. Create a connection
Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings("cnn"))
cnn.Open()
'You must open the db connection before populating the DataReader
'
'2. Create a command object for the query
Dim myBindingCommand As New SqlCommand("SELECT * FROM ProductRestrictions", cnn)
'
'3. Create/Populate the DataReader
Dim result As SqlDataReader = myBindingCommand.ExecuteReader(CommandBehavior.CloseConnection)
'
dgUpdateProductRestrictions.DataSource = result
dgUpdateProductRestrictions.DataBind()
End Sub
'
'Makes controls appear (Like the text box controls) when clicked
'
Sub dgProducts_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
dgUpdateProductRestrictions.EditItemIndex = e.Item.ItemIndex
BindData()
End Sub
'
'Cancel when button is fired
'
Sub dgProducts_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
dgUpdateProductRestrictions.EditItemIndex = -1
BindData()
End Sub
'
'UpDate OnClick This Fires
'
Sub dgProducts_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
'
'Read in the values of the updated row
'ID'S
Dim IDProduct As Integer = e.Item.Cells(1).Text
'ID'S
Dim MaximumWidth As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim MaximumLength As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim MinimumWidthForLiftTilt As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim InsideMount As String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim OutsideMount As String = CType(e.Item.Cells(6).Controls(0), TextBox).Text
Dim ControlTilt As String = CType(e.Item.Cells(7).Controls(0), TextBox).Text
Dim StackingFormulas As String = CType(e.Item.Cells(8).Controls(0), TextBox).Text
Dim RestrictFive As String = CType(e.Item.Cells(9).Controls(0), TextBox).Text
Dim RestrictSix As String = CType(e.Item.Cells(10).Controls(0), TextBox).Text
Dim RestrictSeven As String = CType(e.Item.Cells(11).Controls(0), TextBox).Text
Dim RestrictEight As String = CType(e.Item.Cells(12).Controls(0), TextBox).Text
Dim RestrictNine As String = CType(e.Item.Cells(13).Controls(0), TextBox).Text
Dim RestrictTen As String = CType(e.Item.Cells(14).Controls(0), TextBox).Text
Dim RestrictEleven As String = CType(e.Item.Cells(15).Controls(0), TextBox).Text
Dim RestrictTwelve As String = CType(e.Item.Cells(16).Controls(0), TextBox).Text
'
'Get the connection
'
Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings("cnn"))
cnn.Open()
'
'Set the command
'
Dim myCommand As New SqlCommand("SprocInsertProductRestrictive", cnn)
myCommand.CommandType = CommandType.StoredProcedure
'
'Add Parameters to the SQL query
'
Dim paramIDProduct As SqlParameter = New SqlParameter("@IDProduct", SqlDbType.Int, 4)
paramIDProduct.Value = IDProduct
myCommand.Parameters.Add(paramIDProduct)
'
Dim paramMaximumWidth As SqlParameter = New SqlParameter("@MaximumWidth", SqlDbType.VarChar, 3800)
paramMaximumWidth.Value = MaximumWidth
myCommand.Parameters.Add(paramMaximumWidth)
'
Dim paramMaximumLength As SqlParameter = New SqlParameter("@MaximumLength", SqlDbType.VarChar, 3800)
paramMaximumLength.Value = MaximumLength
myCommand.Parameters.Add(paramMaximumLength)
'
Dim paramMinimumWidthForLiftTilt As SqlParameter = New SqlParameter("@MinimumWidthForLiftTilt", SqlDbType.VarChar, 3800)
paramMinimumWidthForLiftTilt.Value = MinimumWidthForLiftTilt
myCommand.Parameters.Add(paramMinimumWidthForLiftTilt)
'
Dim paramInsideMount As SqlParameter = New SqlParameter("@InsideMount", SqlDbType.VarChar, 3800)
paramInsideMount.Value = InsideMount
myCommand.Parameters.Add(paramInsideMount)
'
Dim paramOutsideMount As SqlParameter = New SqlParameter("@OutsideMount", SqlDbType.VarChar, 3800)
paramOutsideMount.Value = OutsideMount
myCommand.Parameters.Add(paramOutsideMount)
'
Dim paramControlTilt As SqlParameter = New SqlParameter("@ControlTilt", SqlDbType.VarChar, 3800)
paramControlTilt.Value = ControlTilt
myCommand.Parameters.Add(paramControlTilt)
'
Dim paramStackingFormulas As SqlParameter = New SqlParameter("@StackingFormulas", SqlDbType.VarChar, 3800)
paramStackingFormulas.Value = StackingFormulas
myCommand.Parameters.Add(paramStackingFormulas)
'
Dim paramRestrictFive As SqlParameter = New SqlParameter("@RestrictFive", SqlDbType.VarChar, 3800)
paramRestrictFive.Value = RestrictFive
myCommand.Parameters.Add(paramRestrictFive)
'
Dim paramRestrictSix As SqlParameter = New SqlParameter("@RestrictSix", SqlDbType.VarChar, 3800)
paramRestrictSix.Value = RestrictSix
myCommand.Parameters.Add(paramRestrictSix)
'
Dim paramRestrictSeven As SqlParameter = New SqlParameter("@RestrictSeven", SqlDbType.VarChar, 3800)
paramRestrictSeven.Value = RestrictSeven
myCommand.Parameters.Add(paramRestrictSeven)
'
Dim paramRestrictEight As SqlParameter = New SqlParameter("@RestrictEight", SqlDbType.VarChar, 3800)
paramRestrictEight.Value = RestrictEight
myCommand.Parameters.Add(paramRestrictEight)
'
Dim paramRestrictNine As SqlParameter = New SqlParameter("@RestrictNine", SqlDbType.VarChar, 3800)
paramRestrictNine.Value = RestrictNine
myCommand.Parameters.Add(paramRestrictNine)
'
Dim paramRestrictTen As SqlParameter = New SqlParameter("@RestrictTen", SqlDbType.VarChar, 3800)
paramRestrictTen.Value = RestrictTen
myCommand.Parameters.Add(paramRestrictTen)
'
Dim paramRestrictEleven As SqlParameter = New SqlParameter("@RestrictEleven", SqlDbType.VarChar, 3800)
paramRestrictEleven.Value = RestrictEleven
myCommand.Parameters.Add(paramRestrictEleven)
'
Dim paramRestrictTwelve As SqlParameter = New SqlParameter("@RestrictTwelve", SqlDbType.VarChar, 3800)
paramRestrictTwelve.Value = RestrictTwelve
myCommand.Parameters.Add(paramRestrictTwelve)
'
myCommand.ExecuteNonQuery() 'Execute the UPDATE query
'
cnn.Close()
'
'Finally, set the EditItemIndex to -1 and rebind the DataGrid
'
dgUpdateProductRestrictions.EditItemIndex = -1
BindData()
End Sub
|
|
|
|
|
Hi guys,
I want to know how to make a chatting program like yahoo and msn messenger that you can install it on the computer and connect it with the server through the internet that using sql server 2000 database ?
thanks
|
|
|
|
|
|
Hi
i repeat here cause i didn't get answer about how ?
and i get about "Search"
i want explanation about that
thanks
|
|
|
|
|
You didn't get the answer that you wanted. I suggest you start searching and reading because the answers that you want are WAY TOO LARGE to post in any forum. Next time, try asking a more specific question about what you don't understand. Don't ask a qeustion about getting a documentry made about the in's and out's of what you want to write.
The ability to do research, on your own, and learn the skills you need on-the-fly is the PRIMARY skill you need to survive in this business.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks again for your response but i have a few comment about what you wrote,
1-If about searching the web i can search the web its not a problem, but here i didnt search instead of that i put my question here and there is alot of programmer here and maybe i can find a solution for my question.
2-If my question is very wide you can put a points that facilitate the things that are wide and to clarify for the questioner the points that he must take into consideration.
Thanks alot again for your response
with best wishes
|
|
|
|
|
smart_sdr wrote:
If my question is very wide you can put a points that facilitate the things that are wide and to clarify for the questioner the points that he must take into consideration.
What do you think I did in response to your first post?!?!?!?!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
oooohhhh don't be upset my fellow i didn't want to upset you but understand this, i will give an example for this :
if someone said that he want to make database system and he want to use this with the vb.net and he asked about how to do it ?
this is also a wide question cause what type of a database he want to use and about what he want to make his database system through the internet or just by using a local area network ?
and you can give this answer :
my friend i saw your question but if you want to make a database system you must take this into consideration :
1- you can use access database or sql server 2000 or oracle .
2- you can make your system working through the internet and you must use asp.net or if you like php with mySQL .
3- you can make your system work only on the lan (local area network) and in this situation you need vb.net and one of the database that i mentioned it into the point 1.
4- and for now i will give some info about using vb.net with sql :
4a- you must know the vb.net syntax and object oriented programming and about to connect with the database.
for example i mention you this book "Visual Basic.Net programming with Peter Aitken" at http://bookpool.com/sm/1932111166
4b- you must know about the sql server and for the beginning i mention you this book "Wrox - Visual Studio .NET - Beginning Visual Basic .NET Database Programming"
at http://support.apress.com/books.asp?bID=1861005555&s=0&Go=Select+Book
and in this book they will use sql server 2000 Desktop that you can download it from the internet from the microsoft site.
this is just afew info to give a start point for what you want.
thanks.
----------------------------------
this is an example, Dave let us to see what you wrote to me :
"Well, knowledge of TCP/IP would help alot. How to write clients that communicate using sockets, and most of all how to write a multi-threaded socket server. Just search the articles for "CHAT" and you'll come up with a bunch of examples.
I fail to see how an SQL Server figures into this, unless you're going to be logging everything everyone says."
1-"Well, knowledge of TCP/IP would help alot"
*this is a wide info, what you mean with this about studying the networking (network programming or just networking theories ) ?
2-"How to write clients that communicate using sockets"
*without specification about how to make it or if there's a book that talking about that ?
3-"and most of all how to write a multi-threaded socket server"
*also like the point 2
4-"Just search the articles for "CHAT" and you'll come up with a bunch of examples."
*i wrote the "CHAT" in the google and i got 98,600,000 pages !!!
and i wrote it in the yahoo and i got 438,000,000 !!!
5-"I fail to see how an SQL Server figures into this, unless you're going to be logging everything everyone says."
*this is your sight about this.
Dave don't be upset and thanks again for your response i want you for me to be my friend.
im a programmer also since 1995 and i used the assembly programming on motorola processors like amiga 500 and amiga 1200 and also with the processor 68030 accelerator and i was a cracker on the amiga computer. and then i moved to the pc and i studied the reverse engineering and i became a cracker on the pc also but now i left this side and i made a cd copy protection program by using VC++,and about the structure of the pe (exe file portable executable) and also about the data structure of the cd image file format and also about what i knew from the cracking part and also about aspi (advanced scsi II programming interface).
then i tried to make a 3d game and i studied the VC++ (api mode) Application Programming Interface and Direct X 7 and then i moved to the DirectX 9 but i left it also cause i was alone (programmer) and my brother knows about 3d studio max but also its hard to make a 3d game without a team cause there is a lot of studying that i must make about
physics for games and mathematics for games and AI (Artificial Intelligent) and also about alot of stuff.
and then im using the vb.net and sql server to make a business
and i learned about the sql server since afew months.
again nice to meet you
and im sorry if i made you upset
with best wishes
smart_sdr
|
|
|
|
|
Ok, here we go...
smart_sdr wrote:
1-"Well, knowledge of TCP/IP would help alot"
*this is a wide info, what you mean with this about studying the networking (network programming or just networking theories ) ?
Yes, TCP/IP theory covers entire books. Amazon.com is a good place to start. Without this knowledge, you can't even begin to understand the programming required to make your application work. Especially when dealing with firewalls and NAT's.
smart_sdr wrote:
2-"How to write clients that communicate using sockets"
*without specification about how to make it or if there's a book that talking about that ?
Again, an entire book. I defer to Amazon and your ability to evaluate your own experience and skills to pick an appropriate book for yourself.
smart_sdr wrote:
3-"and most of all how to write a multi-threaded socket server"
*also like the point 2
Same book as 2...
smart_sdr wrote:
4-"Just search the articles for "CHAT" and you'll come up with a bunch of examples."
*i wrote the "CHAT" in the google and i got 98,600,000 pages !!!
and i wrote it in the yahoo and i got 438,000,000 !!!
I said search the ARTICLES, not Google. Let me make it easy for you, click here[^].
smart_sdr wrote:
5-"I fail to see how an SQL Server figures into this, unless you're going to be logging everything everyone says."
*this is your sight about this.
I still have no idea how you're going to use an SQL server in a Chat application. You never said what you wanted to do with it in relation to chat.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|