无法将数据插入Microsoft SQL Server

编程入门 行业动态 更新时间:2024-10-27 22:21:31
本文介绍了无法将数据插入Microsoft SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

目前,我正在使用asp开发一个Web应用程序.但是我无法将数据插入数据库.可以提供任何示例代码吗?

Currently I''m develop a web application using asp. But I unable to insert data into database.Any sample code can be provided?

Dim constring As String = "Data Source = USER-PC\SQLEXPRESS; Initial catalog = PatientDiagnose; Persist Security Info= True; User ID = Thalassemia; Password = Ling123!@#" Dim con As SqlConnection = New SqlConnection(constring) Dim ds As New DataSet Dim adapter As New SqlDataAdapter con.Open() Dim insertCommand As String = "Insert into DoctorRecord (DocFirst,DocLast) values (' " & TextBoxFirst.Text & ", " & TextBoxLast.Text & "')" adapter.SelectCommand = New SqlCommand(insertCommand, con) adapter.Fill(ds) Error: There are more columns in the INSERT statement than the values specified in the VALUES clause.

推荐答案

如果您发布了确切的代码,请使用Dorababu743的解决方案 if you have posted exact code then go with the solution of Dorababu743

您错过了一些引号字符.替换一个: You have missed some quote characters. Replace this one : Dim insertCommand As String = "Insert into DoctorRecord (DocFirst,DocLast) values (' " & TextBoxFirst.Text & ", " &

有了这个:

With this one :

Dim insertCommand As String = "Insert into DoctorRecord (DocFirst,DocLast) values ('" & TextBoxFirst.Text & "', '" &

第一个代码将两个字符串包含在一个带引号的字符串中,因此您会看到该错误. 希望对您有帮助.

The first code embraces two strings into one quoted string so you see that error. Hope It Helps.

请提供示例以继续进行操作. 告诉我错误您得到了什么 Please provide sample to proceed further. Tell me the error what you getting

更多推荐

无法将数据插入Microsoft SQL Server

本文发布于:2023-10-12 17:40:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485414.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   Microsoft   Server   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!