|
You're going to buy it - why do you need our comments ? This sounds like an ad to me.
Either way, don't crosspost this crap here, it's not appropriate. Try the lounge if you haven't already and you really want to post this stuff.
$61 for a lousy button ? You must be kidding.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'll read 512 bytes from a file with loop.Using API function CreateFile() open file and using API function ReadFile read file.generally,the file pointer auto move 512 bytes,but the file pointer not move,always at begin head.How to move file pointer.
|
|
|
|
|
It does move on it's own. How are you reading the file and why are you using the Win32 API to do this?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
hellow to all
i am looking for a tutorial or code on working with graphics in vb .
like building Rectangels and ellipse , filling them and all this stuff ..
where can i find ?
thxx a lot
|
|
|
|
|
VB6 or VB.NET ? msdn.microsoft.com has all the GDI+ docs for VB.NET, and my GDI+ articles translate pretty easily to VB.NET also.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
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
|
|
|
|
|
|