473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

DATAGRID+SQL: INSERT - works, but SELECT - not :-(

Hello.

Does anybody had problem with VB application with MS SQL Database?

I have DATAGRID which shows TABLE from DATABASE.

Next I add new ROW to TABLE with SQLcommand (stored procedure)

Command works everytime - I see in database that new rows are added.

After adding new row I "refresh" DATAGRID and I see new rows.

But It works only 2-3 times (about 20 seconds)

I wrote "refresh" in brackets because it is not refreshing but calling
procedure to show VIEW from database.

Is it possible that after few second application is blocked by Database and
I can add rows but can select rows to see them in datagrid?

This is procedure to show table in datagrid:
----------------------------------------------------
Public Sub Wyswietl_Paczki()

Dim conPaczki As New SqlClient.SqlConnection

Dim comWyswietlPaczki As New SqlClient.SqlCommand

Dim daPaczki As New SqlClient.SqlDataAdapter

Dim dsPaczki As New DataSet

conPaczki.ConnectionString = "workstation id=CHREO;packet
size=4096;integrated security=SSPI;" & _

"data source=CHREO;persist security info=False;initial catalog=marketing"

With comWyswietlPaczki

..Connection = conPaczki

..CommandText = "SELECT * FROM " & "PACZKI_Z_AKCJI" &
"(@ID_AKCJA,@DATA_OD,@DATA_DO)"

..Parameters.Add("@ID_AKCJA", SqlDbType.Int)

..Parameters.Add("@DATA_OD", SqlDbType.SmallDateTime)

..Parameters.Add("@DATA_DO", SqlDbType.SmallDateTime)

..Parameters(0).Value = Akcja

..Parameters(1).Value = datOd.Value

..Parameters(2).Value = datDo.Value

End With

daPaczki.SelectCommand = comWyswietlPaczki

daPaczki.Fill(dsPaczki, "PACZKI")

dgrPaczki.DataSource = dsPaczki.Tables("PACZKI")
Nov 21 '05 #1
1 1945
hello Chreo
do you use transactions in stored procedure that add new row in database?
if you do then be sure that it is commited pior trying to display new row in
your application
the problem is not in your code I think.
maybe there is some transaction deal with your database

good luck
Galin Iliev
[MCSD, MCAD.NET]

"chreo" <ch***@gazeta.pl> wrote in message
news:d3**********@inews.gazeta.pl...
Hello.

Does anybody had problem with VB application with MS SQL Database?

I have DATAGRID which shows TABLE from DATABASE.

Next I add new ROW to TABLE with SQLcommand (stored procedure)

Command works everytime - I see in database that new rows are added.

After adding new row I "refresh" DATAGRID and I see new rows.

But It works only 2-3 times (about 20 seconds)

I wrote "refresh" in brackets because it is not refreshing but calling
procedure to show VIEW from database.

Is it possible that after few second application is blocked by Database
and I can add rows but can select rows to see them in datagrid?

This is procedure to show table in datagrid:
----------------------------------------------------
Public Sub Wyswietl_Paczki()

Dim conPaczki As New SqlClient.SqlConnection

Dim comWyswietlPaczki As New SqlClient.SqlCommand

Dim daPaczki As New SqlClient.SqlDataAdapter

Dim dsPaczki As New DataSet

conPaczki.ConnectionString = "workstation id=CHREO;packet
size=4096;integrated security=SSPI;" & _

"data source=CHREO;persist security info=False;initial catalog=marketing"

With comWyswietlPaczki

.Connection = conPaczki

.CommandText = "SELECT * FROM " & "PACZKI_Z_AKCJI" &
"(@ID_AKCJA,@DATA_OD,@DATA_DO)"

.Parameters.Add("@ID_AKCJA", SqlDbType.Int)

.Parameters.Add("@DATA_OD", SqlDbType.SmallDateTime)

.Parameters.Add("@DATA_DO", SqlDbType.SmallDateTime)

.Parameters(0).Value = Akcja

.Parameters(1).Value = datOd.Value

.Parameters(2).Value = datDo.Value

End With

daPaczki.SelectCommand = comWyswietlPaczki

daPaczki.Fill(dsPaczki, "PACZKI")

dgrPaczki.DataSource = dsPaczki.Tables("PACZKI")

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tonya | last post by:
Hi, I wanted to know how i could get rid of the final row that appears in a datagrid (The one where a new row can be entered). can anyone point me in the right direction?? thx in advance
1
by: selen | last post by:
Hello Can I select the cell in datagrid? and can I read its text. I cant do it asp.net in c#... Thanks
0
by: Christopher | last post by:
I AM GETTING A SYSTEM.DATA.SQLCLIENT.SQLEXCEPTION ERROR WHEN ATTEMPTING TO INSERT DATA INTO A SINGLE TABLE THROUGH A GRID //If this is due to a spelling error, i will //inflict a ritual...
0
by: Raj Chudasama | last post by:
how can i select all rows in a datagrid also how can add checkbox to each of my rows in datagrid. I tried to use DataGridColumnStyle but failed try {
1
by: Goober at christianDOTnet | last post by:
A friend of mine is doing some datagrids on a web page, and was using the SQL data adapter on the design view of the page. He is sorting the datagrid on each of the columns as a user clicks on...
0
by: Roger | last post by:
I have some code that uses a SQL Stored procedure to return some rows. I would then like to have these rows show up in a datagrid. sqlCmd = New SqlClient.SqlCommand("R_GetSiphonDetail", sCon)...
1
by: Joey | last post by:
I am using a datagrid with a SELECT button to determine which record to delete. The code behind pulls the selected item's record number (via a hidden column) in the grid with...
2
by: pmcguire | last post by:
I have a form displaying information from one record in a datatable and a datagrid displaying "child" information from records in another, related, datatable. I have added a DatagridTableStyle so...
1
by: schapopa | last post by:
Hi Everybody, I have a datagrid and I am using sqlcommandbuilder for update and insert of the data. I have two questions related to insert new row in datagrid. When I get to the new row how...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.