سلام من يه مشكلي پيدا كردم در دستور insert در vb.net
دستور من در پايگاهم كه sql مي باشد به طريق زير است
REATE PROCEDURE insert_kala @CodeKala smallint ,
@NameFarsi nvarchar(50),
@NameLatin nvarchar(50),
@BarCode char (10),
@CodeVahed tinyint,
@CodeType tinyint,
@PointClosed smallint,
@PointOrder smallint,
@EndPriceEnter money,
@EndPriceForosh money
AS
insert into kala values (@CodeKala,@NameFarsi,@NameLatin,@BarCode,@CodeVahed,1 ,@CodeType,@PointClosed ,@PointOrder ,@EndPriceEnter ,@EndPriceForosh)
GO
و در vb.net
Me.OdbKala.Open()
'/select codevahed
Me.Odbcmdkala.CommandType = CommandType.Text
Me.Odbcmdkala.CommandText = "exec SELECT_VahedCOD '" + Me.CmboVahed.Text.Trim + "'"
Me.Odbcmdkala.Parameters.Clear()
Dim RDR As Odbc.OdbcDataReader = Me.Odbcmdkala.ExecuteReader
If RDR.Read() Then
CodeVahed = RDR(0).ToString
End If
RDR.Close()
''/Select_CodTypekala
Me.Odbcmdkala.CommandType = CommandType.Text
Me.Odbcmdkala.CommandText = "exec Select_CodTypekala'" + Me.CmboTypekala.Text.Trim + "'"
Me.Odbcmdkala.Parameters.Clear()
Dim RDR2 As Odbc.OdbcDataReader = Me.Odbcmdkala.ExecuteReader
While RDR2.Read
codeTypekala = RDR2(0).ToString
End While
RDR2.Close()
Me.Odbcmdkala.CommandType = CommandType.Text
Try
Me.Odbcmdkala.CommandText = "exec insert_kala'" + Me.txtcodekala.Text.Trim + "','" + Me.txtnamefarsi.Text.Trim + "','" + Me.txtnamelatin.Text.Trim + "','" + Me.txtbarcode.Text.Trim + "','" + CodeVahed.ToString + "','" + codeTypekala.ToString + "','" + Me.txtnoghtemasdood.Text.Trim + "','" + Me.txtorder.Text.Trim + "','" + Me.txtendpricevorod.Text.Trim + "','" + Me.txtendpriceforosh.Text.Trim + "'"
Me.Odbcmdkala.Parameters.Clear()
Me.Odbcmdkala.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Me.Odbcmdkala.Dispose()
Me.OdbKala.Close()
و هنگامي كه مي خواهم ذخيره را اناج بدهم با پيغام خطا مواجه مي شوم
لطفا من را راهنمايي كنيد
پيغام خطا به شرح زير مي باشد:
system.nullrefere nceExseptionbject reference not set to an instance of an object at windows application1 .frmkala1.btnsave_click(object sender ,EventArgs e)in
f:\anbar\anbar\anbar\anbar\frmkala1.vb:line147
خواهش ميكنم راهنماييم كنيد
دستور من در پايگاهم كه sql مي باشد به طريق زير است
REATE PROCEDURE insert_kala @CodeKala smallint ,
@NameFarsi nvarchar(50),
@NameLatin nvarchar(50),
@BarCode char (10),
@CodeVahed tinyint,
@CodeType tinyint,
@PointClosed smallint,
@PointOrder smallint,
@EndPriceEnter money,
@EndPriceForosh money
AS
insert into kala values (@CodeKala,@NameFarsi,@NameLatin,@BarCode,@CodeVahed,1 ,@CodeType,@PointClosed ,@PointOrder ,@EndPriceEnter ,@EndPriceForosh)
GO
و در vb.net
Me.OdbKala.Open()
'/select codevahed
Me.Odbcmdkala.CommandType = CommandType.Text
Me.Odbcmdkala.CommandText = "exec SELECT_VahedCOD '" + Me.CmboVahed.Text.Trim + "'"
Me.Odbcmdkala.Parameters.Clear()
Dim RDR As Odbc.OdbcDataReader = Me.Odbcmdkala.ExecuteReader
If RDR.Read() Then
CodeVahed = RDR(0).ToString
End If
RDR.Close()
''/Select_CodTypekala
Me.Odbcmdkala.CommandType = CommandType.Text
Me.Odbcmdkala.CommandText = "exec Select_CodTypekala'" + Me.CmboTypekala.Text.Trim + "'"
Me.Odbcmdkala.Parameters.Clear()
Dim RDR2 As Odbc.OdbcDataReader = Me.Odbcmdkala.ExecuteReader
While RDR2.Read
codeTypekala = RDR2(0).ToString
End While
RDR2.Close()
Me.Odbcmdkala.CommandType = CommandType.Text
Try
Me.Odbcmdkala.CommandText = "exec insert_kala'" + Me.txtcodekala.Text.Trim + "','" + Me.txtnamefarsi.Text.Trim + "','" + Me.txtnamelatin.Text.Trim + "','" + Me.txtbarcode.Text.Trim + "','" + CodeVahed.ToString + "','" + codeTypekala.ToString + "','" + Me.txtnoghtemasdood.Text.Trim + "','" + Me.txtorder.Text.Trim + "','" + Me.txtendpricevorod.Text.Trim + "','" + Me.txtendpriceforosh.Text.Trim + "'"
Me.Odbcmdkala.Parameters.Clear()
Me.Odbcmdkala.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Me.Odbcmdkala.Dispose()
Me.OdbKala.Close()
و هنگامي كه مي خواهم ذخيره را اناج بدهم با پيغام خطا مواجه مي شوم
لطفا من را راهنمايي كنيد
پيغام خطا به شرح زير مي باشد:
system.nullrefere nceExseptionbject reference not set to an instance of an object at windows application1 .frmkala1.btnsave_click(object sender ,EventArgs e)in
f:\anbar\anbar\anbar\anbar\frmkala1.vb:line147
خواهش ميكنم راهنماييم كنيد